### Question:
WarpAutenticationManager { public void createUser(AuthIdentity warpUserCredentials) throws CommunicationException { updateUser(warpUserCredentials.getUser(), warpUserCredentials); } WarpAutenticationManager(
            Client jerseyClient, String warpServerAddr, String warpAdminUser,
            String warpAdminPassword); AuthIdentity getUser(String userName); void removeUser(String userName); void createUser(AuthIdentity warpUserCredentials); void updateUser(
            String currentUserName,
            AuthIdentity newUserCredentials);  }### Answer:
@Test public void testCreateUser() throws Exception { final AuthIdentity authIdentity = new AuthIdentity("joe", "joe"); context.checking( new Expectations() { { oneOf(client).removeAllFilters(); oneOf(client).addFilter( with(equal(new BasicAuthFilter("admin", "lamepass")))); oneOf(client).resource( new URI("http: will(returnValue(resource)); oneOf(resource).accept(MediaType.APPLICATION_JSON_TYPE); oneOf(resource).put(with(anAuthIdentity(authIdentity))); } }); warpAutenticationManager.createUser(authIdentity); context.assertIsSatisfied(); }
@Test public void testCreateOrUpdateUserError() throws Exception { final AuthIdentity authIdentity = new AuthIdentity("joe", "joe"); context.checking( new Expectations() { { oneOf(client).removeAllFilters(); oneOf(client).addFilter( with(equal(new BasicAuthFilter("admin", "lamepass")))); oneOf(client).resource( new URI("http: will(returnValue(resource)); oneOf(resource).accept(MediaType.APPLICATION_JSON_TYPE); oneOf(resource).put(with(anAuthIdentity(authIdentity))); will(throwException(expectedException)); } }); try { warpAutenticationManager.createUser(authIdentity); fail("Expected an exception here"); } catch (WarpAutenticationManager.CommunicationException e) { } context.assertIsSatisfied(); }