TargetConfiguratorImpl implements ITargetConfigurator { @Override public void reportCandidate( TargetHandlerParameters parameters, Instance scopedInstance ) { String key = parameters.getApplicationName() + "_" + parameters.getScopedInstancePath(); this.candidates.put( key, new TargetConfiugrationBean( parameters, scopedInstance )); }  @Override void start(); @Override void stop(); void setTargetHandlerResolver( ITargetHandlerResolver targetHandlerResolver ); @Override void reportCandidate( TargetHandlerParameters parameters, Instance scopedInstance ); @Override void cancelCandidate( TargetHandlerParameters parameters, Instance scopedInstance ); @Override void verifyCandidates();  }
@Test public void testReportCandidate_sameInstancePath_differentApplications() throws Exception { for( int i=1; i<4; i++ ) { TestApplication app = new TestApplication(); app.setName( "app" + i ); TargetHandlerParameters parameters = new TargetHandlerParameters() .applicationName( app.getName()) .scopedInstancePath( InstanceHelpers.computeInstancePath( app.getMySqlVm())) .domain( "domain" ) .targetConfigurationScript( this.folder.newFile()); this.targetConfigurator.reportCandidate( parameters, app.getMySqlVm()); Assert.assertEquals( i, this.targetConfigurator.candidates.size()); } }
@Test public void testReportCandidate_noConfigScript() throws Exception { TestApplication app = new TestApplication(); app.setName( "app" ); TargetHandlerParameters parameters = new TargetHandlerParameters() .applicationName( app.getName()) .scopedInstancePath( InstanceHelpers.computeInstancePath( app.getMySqlVm())) .domain( "domain" ) .targetConfigurationScript( null ); this.targetConfigurator.reportCandidate( parameters, app.getMySqlVm()); Assert.assertEquals( 1, this.targetConfigurator.candidates.size()); }
@Test public void testReportCandidate_inexistingConfigScript() throws Exception { TestApplication app = new TestApplication(); app.setName( "app" ); File f = this.folder.newFile(); Assert.assertTrue( f.delete()); TargetHandlerParameters parameters = new TargetHandlerParameters() .applicationName( app.getName()) .scopedInstancePath( InstanceHelpers.computeInstancePath( app.getMySqlVm())) .domain( "domain" ) .targetConfigurationScript( f ); this.targetConfigurator.reportCandidate( parameters, app.getMySqlVm()); Assert.assertEquals( 1, this.targetConfigurator.candidates.size()); }