use of org.motechproject.security.domain.MotechPermission in project motech by motech.
the class MotechPermissionServiceTest method shouldDeletePermissions.
@Test
public void shouldDeletePermissions() {
MotechPermission permission = mock(MotechPermission.class);
when(motechPermissionsDataService.findByPermissionName("permName")).thenReturn(permission);
permissionService.deletePermission("permName");
verify(motechPermissionsDataService).delete(permission);
}
use of org.motechproject.security.domain.MotechPermission in project motech by motech.
the class MotechPermissionServiceTest method shouldAddPermissions.
@Test
public void shouldAddPermissions() {
PermissionDto permissionDto = new PermissionDto("permName", "bundleName");
permissionService.addPermission(permissionDto);
ArgumentCaptor<MotechPermission> captor = ArgumentCaptor.forClass(MotechPermission.class);
verify(motechPermissionsDataService).create(captor.capture());
assertEquals("permName", captor.getValue().getPermissionName());
assertEquals("bundleName", captor.getValue().getBundleName());
}
use of org.motechproject.security.domain.MotechPermission in project motech by motech.
the class MotechPermissionServiceTest method shouldRefreshUserContextWhenPermissionIsDeleted.
@Test
public void shouldRefreshUserContextWhenPermissionIsDeleted() {
MotechPermission permission = mock(MotechPermission.class);
when(motechPermissionsDataService.findByPermissionName("permName")).thenReturn(permission);
permissionService.deletePermission("permName");
verify(userContextsService).refreshAllUsersContextIfActive();
}
use of org.motechproject.security.domain.MotechPermission in project motech by motech.
the class MotechPermissionServiceBundleIT method shouldNotCreateNewPermissionIfPermissionAlreadyExists.
@Test
public void shouldNotCreateNewPermissionIfPermissionAlreadyExists() {
final String permissionName = "samePersmission";
permissionService.addPermission(new PermissionDto(new MotechPermission(permissionName, "test1")));
permissionService.addPermission(new PermissionDto(new MotechPermission(permissionName, "test2")));
PermissionDto motechPermission = permissionService.findPermissionByName(permissionName);
List<MotechPermission> allPermission = permissionsDataService.retrieveAll();
int numberOfPermissionWithSameName = 0;
for (MotechPermission permission : allPermission) {
if (permissionName.equalsIgnoreCase(permission.getPermissionName())) {
++numberOfPermissionWithSameName;
}
}
assertEquals(1, numberOfPermissionWithSameName);
assertEquals("test1", motechPermission.getBundleName());
}
use of org.motechproject.security.domain.MotechPermission in project motech by motech.
the class MotechPermissionServiceBundleIT method shouldFindByPermissionName.
@Test
public void shouldFindByPermissionName() {
permissionsDataService.create(new MotechPermission("testPermission", "testBundle"));
PermissionDto testPermission = permissionService.findPermissionByName("testPermission");
assertEquals("testPermission", testPermission.getPermissionName());
}
Aggregations