@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; } }
app.setVersion( appDescriptor.getVersion()); app.setDslId( appDescriptor.getDslId()); app.setExternalExportsPrefix( appDescriptor.getExternalExportsPrefix()); app.setTags( appDescriptor.tags );
Assert.assertFalse( iterator.hasNext()); app.setExternalExportsPrefix( "inval!d prefix" ); iterator = RuntimeModelValidator.validate( app ).iterator(); Assert.assertEquals( ErrorCode.RM_INVALID_APPLICATION_EXPORT_PREFIX, iterator.next().getErrorCode()); Assert.assertFalse( iterator.hasNext()); app.setExternalExportsPrefix( "prefix" ); Assert.assertEquals( 0, RuntimeModelValidator.validate( app ).size());