HmsGenericUtil { public static Object maskPassword( Object obj ) { if ( obj != null ) { if ( obj instanceof HmsNode ) { ServerNode copy = new ServerNode(); BeanUtils.copyProperties( obj, copy ); copy.setOsPassword( MASK_DATA ); copy.setManagementUserPassword( MASK_DATA ); return copy; } else if ( obj instanceof SwitchNode ) { SwitchNode copy = new SwitchNode(); BeanUtils.copyProperties( obj, copy ); copy.setPassword( MASK_DATA ); return copy; } } else { logger.warn( "Null input provided" ); } return null; }  static Object maskPassword( Object obj ); static String getBuildVersion(); static BaseResponse getBaseResponse( final Status status, final String errorMessage ); static BaseResponse getBaseResponse( final int statusCode, final String statusMessage,
                                                final String errorMessage ); static void sleepThread( boolean isTaskCompleted, long sleepInterval ); static Map<String, Object> parseJson( String input ); static T parseStringAsValueType( final String content, Class<T> valueType ); static T parseStringAsTypeReference( final String content, TypeReference<T> typeRef ); static String getPayload( T object ); static boolean isHostReachable( String ipAddress ); static void deleteLatestInventoryBackup();  }
@Test public void testMaskPassword() { ServerNode node = new ServerNode(); node.setNodeID( "N1" ); node.setIbIpAddress( "1.2.3.4" ); node.setOsUserName( "root" ); node.setOsPassword( "root123" ); List<EthernetController> ethernetControllerLst = new ArrayList<EthernetController>(); EthernetController ethernetController = new EthernetController(); ethernetController.setComponent( ServerComponent.CPU ); ComponentIdentifier componentIdentifier = new ComponentIdentifier(); componentIdentifier.setDescription( "test" ); ethernetController.setComponentIdentifier( componentIdentifier ); ethernetControllerLst.add( ethernetController ); node.setEthernetControllerList( ethernetControllerLst ); ServerNode copy = (ServerNode) HmsGenericUtil.maskPassword( node ); assertEquals( node.getNodeID(), "N1" ); assertEquals( node.getNodeID(), copy.getNodeID() ); assertEquals( node.getIbIpAddress(), "1.2.3.4" ); assertEquals( node.getIbIpAddress(), copy.getIbIpAddress() ); assertEquals( node.getOsUserName(), "root" ); assertEquals( node.getOsUserName(), copy.getOsUserName() ); assertEquals( node.getOsPassword(), "root123" ); assertNotEquals( node.getOsPassword(), copy.getOsPassword() ); assertEquals( copy.getOsPassword(), "****" ); List<EthernetController> ethernetControllerListOriginal = node.getEthernetControllerList(); List<EthernetController> ethernetControllerListCopy = copy.getEthernetControllerList(); assertEquals( ethernetControllerListOriginal.get( 0 ).getComponent(), ServerComponent.CPU ); assertEquals( ethernetControllerListOriginal.get( 0 ).getComponent(), ethernetControllerListCopy.get( 0 ).getComponent() ); assertEquals( ethernetControllerListOriginal.get( 0 ).getComponentIdentifier().getDescription(), "test" ); assertEquals( ethernetControllerListOriginal.get( 0 ).getComponentIdentifier().getDescription(), ethernetControllerListCopy.get( 0 ).getComponentIdentifier().getDescription() ); }