@Test
public void shouldCreateEnvironmentWithCredentialsIfPresent() throws Exception {

    final String username = "Fred";
    final String password = "Password123";
    final JmxParameters jmxParameters = jmxParameters()
            .withHost("host")
            .withPort(928134)
            .withUsername(username)
            .withPassword(password)
            .build();
    final Map<String, Object> environment = environmentFactory.create(jmxParameters);
    assertThat(environment.size(), is(1));
    final String[] credentialsArray = (String[]) environment.get(CREDENTIALS);
    assertThat(credentialsArray.length, is(2));
    assertThat(credentialsArray[0], is(username));
    assertThat(credentialsArray[1], is(password));
}