### Question:
RelocationState implements State { @Override public boolean isEnabled() { return !dependencyRelocations.isEmpty(); } RelocationState( final Properties userProps ); void initialise( Properties userProps ); @Override boolean isEnabled(); WildcardMap<ProjectVersionRef> getDependencyRelocations(); @ConfigValue( docIndex = "dep-manip.html#dependency-relocations" )
    static final String DEPENDENCY_RELOCATIONS; }### Answer:
@Test public void disabledByDefault() throws ManipulationException { final RelocationState state = new RelocationState( new Properties() ); assertThat( state.isEnabled(), equalTo( false ) ); }
@Test (expected = ManipulationException.class) public void invalidDepRelocationConfig() throws ManipulationException { final Properties p = new Properties(); p.setProperty( RelocationState.DEPENDENCY_RELOCATIONS + "oldGroupId", "" ); final RelocationState state = new RelocationState( p ); assertThat( state.isEnabled(), equalTo( true ) ); }
@Test (expected = ManipulationException.class) public void invalidDepRelocationConfigTwo() throws ManipulationException { final Properties p = new Properties(); p.setProperty( RelocationState.DEPENDENCY_RELOCATIONS + "oldGroupId:newGroupId@", "" ); final RelocationState state = new RelocationState( p ); assertThat( state.isEnabled(), equalTo( true ) ); }
@Test public void testRelocationsWithArtifact() throws ManipulationException { final Properties p = new Properties(); p.setProperty( RelocationState.DEPENDENCY_RELOCATIONS + "oldGroupId:oldArtifactId@newGroupId:newArtifactId", "1.10" ); final RelocationState state = new RelocationState( p ); assertThat( state.isEnabled(), equalTo( true ) ); }
@Test public void testRelocationsWithWildcard() throws ManipulationException { final Properties p = new Properties(); p.setProperty( RelocationState.DEPENDENCY_RELOCATIONS + "oldGroupId:@newGroupId:", "1.10" ); final RelocationState state = new RelocationState( p ); assertThat( state.isEnabled(), equalTo( true ) ); }
@Test public void testRelocationsWithWildcardEmptyVersion() throws ManipulationException { final Properties p = new Properties(); p.setProperty( RelocationState.DEPENDENCY_RELOCATIONS + "oldGroupId:@newGroupId:", "" ); final RelocationState state = new RelocationState( p ); assertThat( state.isEnabled(), equalTo( true ) ); }
@Test(expected = ManipulationException.class) public void testRelocationsWithArtifactInvalid() throws ManipulationException { final Properties p = new Properties(); p.setProperty( RelocationState.DEPENDENCY_RELOCATIONS + "oldGroupId:@newGroupId:newA", "" ); final RelocationState state = new RelocationState( p ); assertThat( state.isEnabled(), equalTo( true ) ); }
@Test (expected = ManipulationException.class) public void testRelocationsWithGroupInvalid() throws ManipulationException { final Properties p = new Properties(); p.setProperty( RelocationState.DEPENDENCY_RELOCATIONS + "oldGroupId:oldA@:newA", "" ); final RelocationState state = new RelocationState( p ); assertThat( state.isEnabled(), equalTo( true ) ); }