@Test( expected = IllegalArgumentException.class ) public void testFindTargetId_nonScopedInstance_strict() throws Exception { TestApplication app = new TestApplication(); String mySqlPath = InstanceHelpers.computeInstancePath( app.getMySql()); this.mngr.findTargetId( app, mySqlPath, true ); }
@Override public String findTargetId( AbstractApplication app, String instancePath, boolean strict ) { InstanceContext key = new InstanceContext( app, instancePath ); String targetId = this.instanceToCachedId.get( key ); Instance inst = InstanceHelpers.findInstanceByPath( app, instancePath ); if( inst != null && ! InstanceHelpers.isTarget( inst )) throw new IllegalArgumentException( "Targets aimed at being queried for scoped instances only. Invalid path: " + instancePath ); if( targetId == null && ! strict ) { if( inst != null ) { key = new InstanceContext( app, "@" + inst.getComponent().getName()); targetId = this.instanceToCachedId.get( key ); } } if( targetId == null && ! strict ) { key = new InstanceContext( app, (String) null ); targetId = this.instanceToCachedId.get( key ); } return targetId; }
TargetsMngrImpl implements ITargetsMngr { @Override public String findTargetId( AbstractApplication app, String instancePath, boolean strict ) { InstanceContext key = new InstanceContext( app, instancePath ); String targetId = this.instanceToCachedId.get( key ); Instance inst = InstanceHelpers.findInstanceByPath( app, instancePath ); if( inst != null && ! InstanceHelpers.isTarget( inst )) throw new IllegalArgumentException( "Targets aimed at being queried for scoped instances only. Invalid path: " + instancePath ); if( targetId == null && ! strict ) { if( inst != null ) { key = new InstanceContext( app, "@" + inst.getComponent().getName()); targetId = this.instanceToCachedId.get( key ); } } if( targetId == null && ! strict ) { key = new InstanceContext( app, (String) null ); targetId = this.instanceToCachedId.get( key ); } return targetId; } }
TargetsMngrImpl implements ITargetsMngr { @Override public String findTargetId( AbstractApplication app, String instancePath, boolean strict ) { InstanceContext key = new InstanceContext( app, instancePath ); String targetId = this.instanceToCachedId.get( key ); Instance inst = InstanceHelpers.findInstanceByPath( app, instancePath ); if( inst != null && ! InstanceHelpers.isTarget( inst )) throw new IllegalArgumentException( "Targets aimed at being queried for scoped instances only. Invalid path: " + instancePath ); if( targetId == null && ! strict ) { if( inst != null ) { key = new InstanceContext( app, "@" + inst.getComponent().getName()); targetId = this.instanceToCachedId.get( key ); } } if( targetId == null && ! strict ) { key = new InstanceContext( app, (String) null ); targetId = this.instanceToCachedId.get( key ); } return targetId; } TargetsMngrImpl( IConfigurationMngr configurationMngr ); }
TargetsMngrImpl implements ITargetsMngr { @Override public String findTargetId( AbstractApplication app, String instancePath, boolean strict ) { InstanceContext key = new InstanceContext( app, instancePath ); String targetId = this.instanceToCachedId.get( key ); Instance inst = InstanceHelpers.findInstanceByPath( app, instancePath ); if( inst != null && ! InstanceHelpers.isTarget( inst )) throw new IllegalArgumentException( "Targets aimed at being queried for scoped instances only. Invalid path: " + instancePath ); if( targetId == null && ! strict ) { if( inst != null ) { key = new InstanceContext( app, "@" + inst.getComponent().getName()); targetId = this.instanceToCachedId.get( key ); } } if( targetId == null && ! strict ) { key = new InstanceContext( app, (String) null ); targetId = this.instanceToCachedId.get( key ); } return targetId; } TargetsMngrImpl( IConfigurationMngr configurationMngr ); @Override String createTarget( String targetContent ); @Override String createTarget( File targetPropertiesFile, ApplicationTemplate creator ); @Override void updateTarget( String targetId, String newTargetContent ); @Override void deleteTarget( String targetId ); @Override void associateTargetWith( String targetId, AbstractApplication app, String instancePathOrComponentName ); @Override void dissociateTargetFrom( AbstractApplication app, String instancePathOrComponentName ); @Override void copyOriginalMapping( Application app ); @Override void applicationWasDeleted( AbstractApplication app ); @Override TargetProperties findTargetProperties( AbstractApplication app, String instancePath ); @Override TargetProperties findTargetProperties( String targetId ); @Override String findTargetId( AbstractApplication app, String instancePath, boolean strict ); @Override String findTargetId( AbstractApplication app, String instancePath ); @Override Map<String,byte[]> findScriptResourcesForAgent( String targetId ); @Override Map<String,byte[]> findScriptResourcesForAgent( AbstractApplication app, Instance scopedInstance ); @Override File findScriptForDm( AbstractApplication app, Instance scopedInstance ); @Override List<TargetWrapperDescriptor> listAllTargets(); @Override TargetWrapperDescriptor findTargetById( String targetId ); @Override List<TargetWrapperDescriptor> listPossibleTargets( AbstractApplication app ); @Override void addHint( String targetId, AbstractApplication app ); @Override void removeHint( String targetId, AbstractApplication app ); @Override TargetProperties lockAndGetTarget( Application app, Instance scopedInstance ); @Override void unlockTarget( Application app, Instance scopedInstance ); @Override List<TargetUsageItem> findUsageStatistics( String targetId ); }
TargetsMngrImpl implements ITargetsMngr { @Override public String findTargetId( AbstractApplication app, String instancePath, boolean strict ) { InstanceContext key = new InstanceContext( app, instancePath ); String targetId = this.instanceToCachedId.get( key ); Instance inst = InstanceHelpers.findInstanceByPath( app, instancePath ); if( inst != null && ! InstanceHelpers.isTarget( inst )) throw new IllegalArgumentException( "Targets aimed at being queried for scoped instances only. Invalid path: " + instancePath ); if( targetId == null && ! strict ) { if( inst != null ) { key = new InstanceContext( app, "@" + inst.getComponent().getName()); targetId = this.instanceToCachedId.get( key ); } } if( targetId == null && ! strict ) { key = new InstanceContext( app, (String) null ); targetId = this.instanceToCachedId.get( key ); } return targetId; } TargetsMngrImpl( IConfigurationMngr configurationMngr ); @Override String createTarget( String targetContent ); @Override String createTarget( File targetPropertiesFile, ApplicationTemplate creator ); @Override void updateTarget( String targetId, String newTargetContent ); @Override void deleteTarget( String targetId ); @Override void associateTargetWith( String targetId, AbstractApplication app, String instancePathOrComponentName ); @Override void dissociateTargetFrom( AbstractApplication app, String instancePathOrComponentName ); @Override void copyOriginalMapping( Application app ); @Override void applicationWasDeleted( AbstractApplication app ); @Override TargetProperties findTargetProperties( AbstractApplication app, String instancePath ); @Override TargetProperties findTargetProperties( String targetId ); @Override String findTargetId( AbstractApplication app, String instancePath, boolean strict ); @Override String findTargetId( AbstractApplication app, String instancePath ); @Override Map<String,byte[]> findScriptResourcesForAgent( String targetId ); @Override Map<String,byte[]> findScriptResourcesForAgent( AbstractApplication app, Instance scopedInstance ); @Override File findScriptForDm( AbstractApplication app, Instance scopedInstance ); @Override List<TargetWrapperDescriptor> listAllTargets(); @Override TargetWrapperDescriptor findTargetById( String targetId ); @Override List<TargetWrapperDescriptor> listPossibleTargets( AbstractApplication app ); @Override void addHint( String targetId, AbstractApplication app ); @Override void removeHint( String targetId, AbstractApplication app ); @Override TargetProperties lockAndGetTarget( Application app, Instance scopedInstance ); @Override void unlockTarget( Application app, Instance scopedInstance ); @Override List<TargetUsageItem> findUsageStatistics( String targetId );  }