@Test
public void lowestPriority() {

    // setup
    DefaultConfigurationBuilder b = new DefaultConfigurationBuilder();
    MockedPropertySource[] propertySources = new MockedPropertySource[10];
    for (int i = 0; i < propertySources.length; i++) {
        propertySources[i] = new MockedPropertySource("ps" + i, i);
    }
    b.addPropertySources(propertySources);
    // test
    b.lowestPriority(propertySources[0]);
    for (int i = 0; i < propertySources.length; i++) {
        assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]);
    }
    b.lowestPriority(propertySources[1]);
    for (int i = 2; i < propertySources.length; i++) {
        assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]);
    }
    assertThat(b.getPropertySources().get(1)).isEqualTo(propertySources[0]);
    assertThat(b.getPropertySources().get(0)).isEqualTo(propertySources[1]);
    b.lowestPriority(propertySources[5]).build();
    assertThat(b.getPropertySources().get(0)).isEqualTo(propertySources[5]);
    boolean caughtAlreadyBuilt = false;
    try {
        b.lowestPriority(propertySources[5]);
    } catch (IllegalStateException e) {
        caughtAlreadyBuilt = true;
    }
    assertThat(caughtAlreadyBuilt).isTrue();
}