use of org.apache.aries.jmx.codec.GroupData in project aries by apache.
the class UserAdminTest method testGetGroup.
/**
* Test method for {@link org.apache.aries.jmx.useradmin.UserAdmin#getGroup(java.lang.String)}.
*
* @throws IOException
*/
@Test
public void testGetGroup() throws IOException {
Group group1 = Mockito.mock(Group.class);
Mockito.when(group1.getType()).thenReturn(Role.GROUP);
Mockito.when(group1.getName()).thenReturn("group1");
Role role1 = Mockito.mock(Role.class);
Mockito.when(role1.getName()).thenReturn("role1");
Role role2 = Mockito.mock(Role.class);
Mockito.when(role2.getName()).thenReturn("role2");
Mockito.when(group1.getRequiredMembers()).thenReturn(new Role[] { role1 });
Mockito.when(group1.getMembers()).thenReturn(new Role[] { role2 });
Mockito.when(userAdmin.getRole(Mockito.anyString())).thenReturn(group1);
CompositeData data = mbean.getGroup("group1");
Assert.assertNotNull(data);
GroupData group = GroupData.from(data);
Assert.assertNotNull(group);
Assert.assertEquals("group1", group.getName());
Assert.assertEquals(Role.GROUP, group.getType());
Assert.assertArrayEquals(new String[] { "role2" }, group.getMembers());
Assert.assertArrayEquals(new String[] { "role1" }, group.getRequiredMembers());
Mockito.verify(userAdmin).getRole(Mockito.anyString());
}
use of org.apache.aries.jmx.codec.GroupData in project aries by apache.
the class UserAdmin method getGroup.
/**
* @see org.osgi.jmx.service.useradmin.UserAdminMBean#getGroup(java.lang.String)
*/
public CompositeData getGroup(String groupname) throws IOException {
if (groupname == null) {
throw new IOException("Group name cannot be null");
}
Role role = userAdmin.getRole(groupname);
if (role == null) {
return null;
}
validateRoleType(role, Role.GROUP);
return new GroupData((Group) role).toCompositeData();
}
Aggregations