use of org.apache.aries.jmx.codec.UserData in project aries by apache.
the class UserAdminTest method testGetUser.
/**
* Test method for {@link org.apache.aries.jmx.useradmin.UserAdmin#getUser(java.lang.String)}.
*
* @throws IOException
*/
@Test
public void testGetUser() throws IOException {
User user1 = Mockito.mock(User.class);
Mockito.when(user1.getType()).thenReturn(Role.USER);
Mockito.when(user1.getName()).thenReturn("user1");
Mockito.when(userAdmin.getRole(Mockito.anyString())).thenReturn(user1);
CompositeData data = mbean.getUser("user1");
Assert.assertNotNull(data);
UserData user = UserData.from(data);
Assert.assertNotNull(user);
Assert.assertEquals("user1", user.getName());
Assert.assertEquals(Role.USER, user.getType());
Mockito.verify(userAdmin).getRole(Mockito.anyString());
}
use of org.apache.aries.jmx.codec.UserData in project aries by apache.
the class UserAdmin method getUser.
/**
* @see org.osgi.jmx.service.useradmin.UserAdminMBean#getUser(java.lang.String)
*/
public CompositeData getUser(String username) throws IOException {
if (username == null) {
throw new IOException("User name cannot be null");
}
Role role = userAdmin.getRole(username);
if (role == null) {
return null;
}
validateRoleType(role, Role.USER);
return new UserData((User) role).toCompositeData();
}
Aggregations