package org.openur.remoting.resource.security;

import java.util.UUID;

import org.glassfish.hk2.api.Factory;
import org.mockito.Mockito;
import org.openur.module.service.security.IAuthorizationServices;

public class MockAuthorizationServicesFactory
	implements Factory<IAuthorizationServices>
{
	static final String APP_NAME = "appName";
	static final String PERMISSION_TEXT = "permissionText";
	static final String OTHER_PERMISSION_TEXT = "otherPermissionText";
	static final String PERSON_ID = UUID.randomUUID().toString();
	static final String OU_ID = UUID.randomUUID().toString();
	
	@Override
	public IAuthorizationServices provide()
	{
		final IAuthorizationServices authorizationServices = Mockito.mock(IAuthorizationServices.class);
		
		Mockito.when(authorizationServices.hasPermission(PERSON_ID, OU_ID, PERMISSION_TEXT, APP_NAME)).thenReturn(Boolean.TRUE);		
		Mockito.when(authorizationServices.hasPermission(PERSON_ID, OU_ID, OTHER_PERMISSION_TEXT, APP_NAME)).thenReturn(Boolean.FALSE);
		Mockito.when(authorizationServices.hasPermission(PERSON_ID, PERMISSION_TEXT, APP_NAME)).thenReturn(Boolean.TRUE);		
		Mockito.when(authorizationServices.hasPermission(PERSON_ID, OTHER_PERMISSION_TEXT, APP_NAME)).thenReturn(Boolean.FALSE);
		
		return authorizationServices;
	}

	@Override
	public void dispose(IAuthorizationServices instance)
	{
	}
}

@@ -291,16 +291,23 @@
 ces%3E%0A%7B%0A%09
+public 
 static f
@@ -337,24 +337,31 @@
 %22appName%22;%0A%09
+public 
 static final
@@ -397,32 +397,39 @@
 rmissionText%22;%0A%09
+public 
 static final Str
@@ -480,16 +480,23 @@
 Text%22;%0A%09
+public 
 static f
@@ -550,16 +550,23 @@
 ing();%0A%09
+public 
 static f

set static fields to 'public'.