### Question:
CassandraConfigurationFileImpl implements CassandraConfiguration { @Override public String user() { return getMandatoryStringValue(CASSANDRA_USER); } @VisibleForTesting  CassandraConfigurationFileImpl(IniFile iniFile); @Override Collection<String> seeds(); @Override String keyspace(); @Override String user(); @Override String password(); @Override int readTimeoutMs(); @Override CassandraRetryPolicy retryPolicy(); @Override int maxRetries();  }### Answer:
@Test(expected=NullPointerException.class) public void testUserNotDefined() { try { expect(iniFile.getStringValue(CassandraConfigurationFileImpl.CASSANDRA_USER)) .andReturn(null); control.replay(); CassandraConfigurationFileImpl cassandraConfigurationFileImpl = new CassandraConfigurationFileImpl(iniFile); cassandraConfigurationFileImpl.user(); } catch (NullPointerException e) { control.verify(); throw e; } }
@Test public void testUser() { String expectedUser = "user"; expect(iniFile.getStringValue(CassandraConfigurationFileImpl.CASSANDRA_USER)) .andReturn(expectedUser); control.replay(); CassandraConfigurationFileImpl cassandraConfigurationFileImpl = new CassandraConfigurationFileImpl(iniFile); String user = cassandraConfigurationFileImpl.user(); control.verify(); assertThat(user).isEqualTo(expectedUser); }