### Question:
User { public String encodeCredentialsForBasicAuthorization() { String credentials = username + ":" + password; String base64EncodedCredentials = encodeToString(credentials.getBytes(), NO_WRAP); return "Basic " + base64EncodedCredentials; } User();  User(String username, String password);  User(String username, String password, String facilityCode);  User(String username, String password, String facilityCode, String facilityName); String getUsername(); String getPassword(); @Override boolean equals(Object o); @Override int hashCode(); String encodeCredentialsForBasicAuthorization(); String getFacilityCode(); void setFacilityCode(String facilityCode); String getFacilityName(); void setFacilityName(String facilityName);  }### Answer:
@Test public void shouldEncodeUsernameAndPasswordForBasicAuth() throws Exception { User user = new User("username", "password"); assertThat(user.encodeCredentialsForBasicAuthorization(), is("Basic dXNlcm5hbWU6cGFzc3dvcmQ=")); }