@Test public void testFindTargetHandler() throws Exception { TargetHandler th1 = Mockito.mock( TargetHandler.class ); Mockito.when( th1.getTargetId()).thenReturn( "t1" ); TargetHandler th2 = Mockito.mock( TargetHandler.class ); Mockito.when( th2.getTargetId()).thenReturn( "t2" ); TargetHandlerResolverImpl mngr = new TargetHandlerResolverImpl(); mngr.addTargetHandler( th1 ); mngr.addTargetHandler( th2 ); Map<String,String> targetProperties = new HashMap<>(); targetProperties.put( Constants.TARGET_PROPERTY_HANDLER, "t2" ); Assert.assertEquals( th2, mngr.findTargetHandler( targetProperties )); targetProperties.put( Constants.TARGET_PROPERTY_HANDLER, "t1" ); Assert.assertEquals( th1, mngr.findTargetHandler( targetProperties )); }
@Override public TargetHandler findTargetHandler( Map<String,String> targetProperties ) throws TargetException { String targetId = TargetHelpers.findTargetHandlerName( targetProperties ); TargetHandler result = null; if( targetId != null ) { for( TargetHandler itf : this.targetHandlers ) { if( targetId.equalsIgnoreCase( itf.getTargetId())) { result = itf; break; } } } if( result == null ) throw new TargetException( "No deployment handler was found for handler named " + targetId ); return result; }
TargetHandlerResolverImpl implements ITargetHandlerResolver { @Override public TargetHandler findTargetHandler( Map<String,String> targetProperties ) throws TargetException { String targetId = TargetHelpers.findTargetHandlerName( targetProperties ); TargetHandler result = null; if( targetId != null ) { for( TargetHandler itf : this.targetHandlers ) { if( targetId.equalsIgnoreCase( itf.getTargetId())) { result = itf; break; } } } if( result == null ) throw new TargetException( "No deployment handler was found for handler named " + targetId ); return result; } }
TargetHandlerResolverImpl implements ITargetHandlerResolver { @Override public TargetHandler findTargetHandler( Map<String,String> targetProperties ) throws TargetException { String targetId = TargetHelpers.findTargetHandlerName( targetProperties ); TargetHandler result = null; if( targetId != null ) { for( TargetHandler itf : this.targetHandlers ) { if( targetId.equalsIgnoreCase( itf.getTargetId())) { result = itf; break; } } } if( result == null ) throw new TargetException( "No deployment handler was found for handler named " + targetId ); return result; }  }
TargetHandlerResolverImpl implements ITargetHandlerResolver { @Override public TargetHandler findTargetHandler( Map<String,String> targetProperties ) throws TargetException { String targetId = TargetHelpers.findTargetHandlerName( targetProperties ); TargetHandler result = null; if( targetId != null ) { for( TargetHandler itf : this.targetHandlers ) { if( targetId.equalsIgnoreCase( itf.getTargetId())) { result = itf; break; } } } if( result == null ) throw new TargetException( "No deployment handler was found for handler named " + targetId ); return result; }  void addTargetHandler( TargetHandler targetItf ); void removeTargetHandler( TargetHandler targetItf ); @Override TargetHandler findTargetHandler( Map<String,String> targetProperties ); List<TargetHandler> getTargetHandlersSnapshot(); static void listTargets( List<TargetHandler> targetHandlers, Logger logger ); }
TargetHandlerResolverImpl implements ITargetHandlerResolver { @Override public TargetHandler findTargetHandler( Map<String,String> targetProperties ) throws TargetException { String targetId = TargetHelpers.findTargetHandlerName( targetProperties ); TargetHandler result = null; if( targetId != null ) { for( TargetHandler itf : this.targetHandlers ) { if( targetId.equalsIgnoreCase( itf.getTargetId())) { result = itf; break; } } } if( result == null ) throw new TargetException( "No deployment handler was found for handler named " + targetId ); return result; }  void addTargetHandler( TargetHandler targetItf ); void removeTargetHandler( TargetHandler targetItf ); @Override TargetHandler findTargetHandler( Map<String,String> targetProperties ); List<TargetHandler> getTargetHandlersSnapshot(); static void listTargets( List<TargetHandler> targetHandlers, Logger logger );  }