### Question:
UserManagementAndSecurityModule implements eu.cloud4soa.api.soa.UserManagementAndSecurityModule { @Override public boolean isAccountNameInUse(String accountName) throws SOAException { boolean accountNameInUse; String accountNameSparql = repositoryManager.getModel().createPlainLiteral(accountName).toSPARQL(); String query = "PREFIX rdf: <http: + "PREFIX user-m: <http: + "PREFIX xsd: <http: + "SELECT ?object ?type WHERE { { ?object rdf:type ?type . ?object <http: + "UNION " + "{ ?object rdf:type ?type . ?object <http: org.ontoware.rdf2go.model.QueryResultTable resultTable = repositoryManager.getModel().sparqlSelect(query); if(resultTable == null){ String error = "An error happens when querying the model"; logger.debug(error); throw new SOAException(Response.Status.INTERNAL_SERVER_ERROR, error); } Iterator<QueryRow> it = resultTable.iterator(); if(it.hasNext()){ accountNameInUse = true; return accountNameInUse; } accountNameInUse = false; return accountNameInUse; }  @Required void setRepositoryManager(RepositoryManager repositoryManager); @Required void setUserProfilesRepository(UserProfilesRepository userProfilesRepository); @Required void setPaaSOfferingProfilesRepository(PaaSOfferingProfilesRepository paaSOfferingProfilesRepository); @Override Response createNewAccount(UserInstance userInstance ,String username, String password); @Override Response storeTurtleUserProfile(String userProfile, String username, String password); @Override UserInstance getUserInstance(String userInstanceUriId); @Override Response updateUserInstance(UserInstance userInstance); @Override //TODO Input pending of actual logging implementation /* UserInstance authenticateUser (String username, String password) throws SOAException { */ UserInstance authenticateUser(String username, String password); @Override boolean isAccountNameInUse(String accountName); @Override Response storeUserCredentialsForPaaS(String userInstanceUriId, String paaSInstanceUriId, String publicKey, String secretKey, String accountName); @Override Response removeUserCredentialsForPaaS(String userInstanceUriId, String paaSInstanceUriId); @Override Response updateUserCredentialsForPaaS(String userInstanceUriId, String paaSInstanceUriId, String publicKey, String secretKey, String accountName); @Override UserPaaSCredentials readUserCredentialsForPaaS(String userInstanceUriId, String paaSInstanceUriId); @Override List<UserPaaSCredentials> readAllUserCredentialsForPaaS(String userInstanceUriId); void close();  }### Answer:
@Test public void TestIsAccountNameInUse() { UserInstance retrivedUserInstance = null; try { retrivedUserInstance = userManagementAndSecurityModule.getUserInstance(userId); } catch (ResourceException e) { Assert.fail("userManagementAndSecurityModule in not able to retrieve an existing user: " + userId); } catch (SOAException ex) { Assert.fail("getUserInstance method has thrown an exception!"); } try { boolean accountNameInUse = userManagementAndSecurityModule.isAccountNameInUse(retrivedUserInstance.getAccountname()); if (accountNameInUse == false) { Assert.fail("userManagementAndSecurityModule has not found the existing account name: " + retrivedUserInstance.getAccountname()); } String nonExistingAccountName = "whatever"; accountNameInUse = userManagementAndSecurityModule.isAccountNameInUse(nonExistingAccountName); if (accountNameInUse == true) { Assert.fail("userManagementAndSecurityModule has not found the existing account name: " + nonExistingAccountName); } } catch (ResourceException e) { Response resp = e.getResponse(); Status.fromStatusCode(resp.getStatus()).equals(Status.BAD_REQUEST); Assert.assertTrue("Different exception code", Status.fromStatusCode(resp.getStatus()).equals(Status.BAD_REQUEST)); } catch (SOAException ex) { Assert.fail("userManagementAndSecurityModule is not able to check if the account name already exists: " + ex.getMessage()); } }