@Override public ApplicationTemplate deserialize( JsonParser parser, DeserializationContext context ) throws IOException { ObjectCodec oc = parser.getCodec(); JsonNode node = oc.readTree( parser ); ApplicationTemplate application = new ApplicationTemplate(); JsonNode n; if(( n = node.get( DISPLAY_NAME )) != null ) application.setName( n.textValue()); else if(( n = node.get( NAME )) != null ) application.setName( n.textValue()); if(( n = node.get( DESC )) != null ) application.setDescription( n.textValue()); if(( n = node.get( VERSION )) != null ) application.setVersion( n.textValue()); if(( n = node.get( EEP )) != null ) application.setExternalExportsPrefix( n.textValue()); if(( n = node.get( APP_TPL_TAGS )) != null ) { for( JsonNode arrayNodeItem : n ) application.addTag( arrayNodeItem.textValue()); } return application; } }
@Override public Application deserialize( JsonParser parser, DeserializationContext context ) throws IOException { ObjectCodec oc = parser.getCodec(); JsonNode node = oc.readTree( parser ); Application application; JsonNode n; if(( n = node.get( APP_INST_TPL_NAME )) != null ) { ApplicationTemplate appTemplate = new ApplicationTemplate(); appTemplate.setName( n.textValue()); n = node.get( APP_INST_TPL_VERSION ); if( n != null ) appTemplate.setVersion( n.textValue()); n = node.get( APP_INST_TPL_EEP ); if( n != null ) appTemplate.setExternalExportsPrefix( n.textValue()); application = new Application( appTemplate ); } else { application = new Application( null ); } if(( n = node.get( DISPLAY_NAME )) != null ) application.setName( n.textValue()); else if(( n = node.get( NAME )) != null ) application.setName( n.textValue()); if(( n = node.get( DESC )) != null ) application.setDescription( n.textValue()); return application; } }
@Test public void testEqualsAndHashCode_1() { ApplicationTemplate app1 = new ApplicationTemplate(); app1.setName( "app" ); app1.setVersion( "snapshot" ); ApplicationTemplate app2 = new ApplicationTemplate(); app2.setName( "app" ); app2.setVersion( "snapshot" ); HashSet<ApplicationTemplate> set = new HashSet<>( 2 ); set.add( app1 ); set.add( app2 ); Assert.assertEquals( 1, set.size()); }
app.setName( appDescriptor.getName()); app.setDescription( appDescriptor.getDescription()); app.setVersion( appDescriptor.getVersion()); app.setDslId( appDescriptor.getDslId()); app.setExternalExportsPrefix( appDescriptor.getExternalExportsPrefix());
Assert.assertFalse( iterator.hasNext()); app.setVersion( "Snapshot Build #2401" ); iterator = RuntimeModelValidator.validate( app ).iterator(); Assert.assertEquals( ErrorCode.RM_INVALID_APPLICATION_VERSION, iterator.next().getErrorCode()); Assert.assertFalse( iterator.hasNext()); app.setVersion( "3.2.4" ); iterator = RuntimeModelValidator.validate( app ).iterator(); Assert.assertEquals( ErrorCode.RM_MISSING_APPLICATION_GRAPHS, iterator.next().getErrorCode());