@Test
public void increasePriority() {

    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);
    b.increasePriority(propertySources[propertySources.length - 1]);
    for (int i = 0; i < propertySources.length; i++) {
        assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]);
    }
    b.increasePriority(propertySources[propertySources.length - 2]).build();
    for (int i = 0; i < propertySources.length - 2; i++) {
        assertThat(b.getPropertySources().get(i)).isEqualTo(propertySources[i]);
    }
    assertThat(b.getPropertySources().get(propertySources.length - 2)).isEqualTo(propertySources[propertySources.length - 1]);
    assertThat(b.getPropertySources().get(propertySources.length - 1)).isEqualTo(propertySources[propertySources.length - 2]);
    boolean caughtAlreadyBuilt = false;
    try {
        b.increasePriority(propertySources[propertySources.length - 2]);
    } catch (IllegalStateException e) {
        caughtAlreadyBuilt = true;
    }
    assertThat(caughtAlreadyBuilt).isTrue();
}