@Test public void verifyProcessedClasses() throws Exception { UpdateSwaggerJson updater = new UpdateSwaggerJson(); updater.prepareNewDefinitions(); Set<Class<?>> classes = new HashSet<> (); classes.addAll( JSonBindingUtils.getSerializers().keySet()); classes.removeAll( updater.processedClasses ); classes.removeAll( Arrays.asList( StringWrapper.class, MapWrapper.class, MappedCollectionWrapper.class, ApplicationBindings.class, WebSocketMessage.class, CommandHistoryItem.class )); Assert.assertEquals( Collections.emptySet(), classes ); }
public JsonObject prepareNewDefinitions() throws IOException { ObjectMapper mapper = JSonBindingUtils.createObjectMapper(); StringWriter writer = new StringWriter(); JsonObject newDef = new JsonObject(); Application app = newTestApplication(); app.bindWithApplication( "externalExportPrefix1", "application 1" ); app.bindWithApplication( "externalExportPrefix1", "application 2" ); app.bindWithApplication( "externalExportPrefix2", "application 3" ); app.setName( "My Application with special chàràcters" ); app.getTemplate().externalExports.put( "internalGraphVariable", "variableAlias" ); app.getTemplate().setExternalExportsPrefix( "externalExportPrefix" ); app.getTemplate().setDescription( "some description" ); writer = new StringWriter(); mapper.writeValue( writer, app ); String s = writer.toString(); convertToTypes( s, Application.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, app.getTemplate()); s = writer.toString(); convertToTypes( s, ApplicationTemplate.class, newDef ); Instance war = InstanceHelpers.findInstanceByPath( app, "/tomcat-vm/tomcat-server/hello-world" ); Objects.requireNonNull( war ); writer = new StringWriter(); mapper.writeValue( writer, war.getComponent()); s = writer.toString(); convertToTypes( s, Component.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, war ); s = writer.toString(); convertToTypes( s, Instance.class, newDef ); Diagnostic diag = new Diagnostic( "/vm1/server1" ); DependencyInformation di = new DependencyInformation( "facetOrComponentName", true, false ); diag.getDependenciesInformation().add( di ); writer = new StringWriter(); mapper.writeValue( writer, diag ); s = writer.toString(); convertToTypes( s, Diagnostic.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, di ); s = writer.toString(); convertToTypes( s, DependencyInformation.class, newDef ); TargetWrapperDescriptor twd = new TargetWrapperDescriptor(); twd.setId( "target-id" ); twd.setDescription( "some description" ); twd.setHandler( "iaas-ec2" ); twd.setName( "target name" ); twd.setDefault( true ); writer = new StringWriter(); mapper.writeValue( writer, twd ); s = writer.toString(); convertToTypes( s, TargetWrapperDescriptor.class, newDef ); TargetUsageItem tui = new TargetUsageItem(); tui.setName( "app or template name" ); tui.setVersion( "template qualifier (null for applications)" ); tui.setReferencing( true ); tui.setUsing( true ); writer = new StringWriter(); mapper.writeValue( writer, tui ); s = writer.toString(); convertToTypes( s, TargetUsageItem.class, newDef ); TargetAssociation ta = new TargetAssociation( "/vm-1", "VM", twd ); writer = new StringWriter(); mapper.writeValue( writer, ta ); s = writer.toString(); convertToTypes( s, TargetAssociation.class, newDef ); Preference pref = new Preference( "key", "value", PreferenceKeyCategory.AUTONOMIC ); writer = new StringWriter(); mapper.writeValue( writer, pref ); s = writer.toString(); convertToTypes( s, Preference.class, newDef ); ScheduledJob job = new ScheduledJob(); job.setAppName( "application name" ); job.setCmdName( "command name" ); job.setCron( "0 0 12 ? * WED" ); job.setJobId( "job-id" ); job.setJobName( "job name" ); writer = new StringWriter(); mapper.writeValue( writer, job ); s = writer.toString(); convertToTypes( s, ScheduledJob.class, newDef ); return newDef; }
UpdateSwaggerJson { public JsonObject prepareNewDefinitions() throws IOException { ObjectMapper mapper = JSonBindingUtils.createObjectMapper(); StringWriter writer = new StringWriter(); JsonObject newDef = new JsonObject(); Application app = newTestApplication(); app.bindWithApplication( "externalExportPrefix1", "application 1" ); app.bindWithApplication( "externalExportPrefix1", "application 2" ); app.bindWithApplication( "externalExportPrefix2", "application 3" ); app.setName( "My Application with special chàràcters" ); app.getTemplate().externalExports.put( "internalGraphVariable", "variableAlias" ); app.getTemplate().setExternalExportsPrefix( "externalExportPrefix" ); app.getTemplate().setDescription( "some description" ); writer = new StringWriter(); mapper.writeValue( writer, app ); String s = writer.toString(); convertToTypes( s, Application.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, app.getTemplate()); s = writer.toString(); convertToTypes( s, ApplicationTemplate.class, newDef ); Instance war = InstanceHelpers.findInstanceByPath( app, "/tomcat-vm/tomcat-server/hello-world" ); Objects.requireNonNull( war ); writer = new StringWriter(); mapper.writeValue( writer, war.getComponent()); s = writer.toString(); convertToTypes( s, Component.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, war ); s = writer.toString(); convertToTypes( s, Instance.class, newDef ); Diagnostic diag = new Diagnostic( "/vm1/server1" ); DependencyInformation di = new DependencyInformation( "facetOrComponentName", true, false ); diag.getDependenciesInformation().add( di ); writer = new StringWriter(); mapper.writeValue( writer, diag ); s = writer.toString(); convertToTypes( s, Diagnostic.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, di ); s = writer.toString(); convertToTypes( s, DependencyInformation.class, newDef ); TargetWrapperDescriptor twd = new TargetWrapperDescriptor(); twd.setId( "target-id" ); twd.setDescription( "some description" ); twd.setHandler( "iaas-ec2" ); twd.setName( "target name" ); twd.setDefault( true ); writer = new StringWriter(); mapper.writeValue( writer, twd ); s = writer.toString(); convertToTypes( s, TargetWrapperDescriptor.class, newDef ); TargetUsageItem tui = new TargetUsageItem(); tui.setName( "app or template name" ); tui.setVersion( "template qualifier (null for applications)" ); tui.setReferencing( true ); tui.setUsing( true ); writer = new StringWriter(); mapper.writeValue( writer, tui ); s = writer.toString(); convertToTypes( s, TargetUsageItem.class, newDef ); TargetAssociation ta = new TargetAssociation( "/vm-1", "VM", twd ); writer = new StringWriter(); mapper.writeValue( writer, ta ); s = writer.toString(); convertToTypes( s, TargetAssociation.class, newDef ); Preference pref = new Preference( "key", "value", PreferenceKeyCategory.AUTONOMIC ); writer = new StringWriter(); mapper.writeValue( writer, pref ); s = writer.toString(); convertToTypes( s, Preference.class, newDef ); ScheduledJob job = new ScheduledJob(); job.setAppName( "application name" ); job.setCmdName( "command name" ); job.setCron( "0 0 12 ? * WED" ); job.setJobId( "job-id" ); job.setJobName( "job name" ); writer = new StringWriter(); mapper.writeValue( writer, job ); s = writer.toString(); convertToTypes( s, ScheduledJob.class, newDef ); return newDef; } }
UpdateSwaggerJson { public JsonObject prepareNewDefinitions() throws IOException { ObjectMapper mapper = JSonBindingUtils.createObjectMapper(); StringWriter writer = new StringWriter(); JsonObject newDef = new JsonObject(); Application app = newTestApplication(); app.bindWithApplication( "externalExportPrefix1", "application 1" ); app.bindWithApplication( "externalExportPrefix1", "application 2" ); app.bindWithApplication( "externalExportPrefix2", "application 3" ); app.setName( "My Application with special chàràcters" ); app.getTemplate().externalExports.put( "internalGraphVariable", "variableAlias" ); app.getTemplate().setExternalExportsPrefix( "externalExportPrefix" ); app.getTemplate().setDescription( "some description" ); writer = new StringWriter(); mapper.writeValue( writer, app ); String s = writer.toString(); convertToTypes( s, Application.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, app.getTemplate()); s = writer.toString(); convertToTypes( s, ApplicationTemplate.class, newDef ); Instance war = InstanceHelpers.findInstanceByPath( app, "/tomcat-vm/tomcat-server/hello-world" ); Objects.requireNonNull( war ); writer = new StringWriter(); mapper.writeValue( writer, war.getComponent()); s = writer.toString(); convertToTypes( s, Component.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, war ); s = writer.toString(); convertToTypes( s, Instance.class, newDef ); Diagnostic diag = new Diagnostic( "/vm1/server1" ); DependencyInformation di = new DependencyInformation( "facetOrComponentName", true, false ); diag.getDependenciesInformation().add( di ); writer = new StringWriter(); mapper.writeValue( writer, diag ); s = writer.toString(); convertToTypes( s, Diagnostic.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, di ); s = writer.toString(); convertToTypes( s, DependencyInformation.class, newDef ); TargetWrapperDescriptor twd = new TargetWrapperDescriptor(); twd.setId( "target-id" ); twd.setDescription( "some description" ); twd.setHandler( "iaas-ec2" ); twd.setName( "target name" ); twd.setDefault( true ); writer = new StringWriter(); mapper.writeValue( writer, twd ); s = writer.toString(); convertToTypes( s, TargetWrapperDescriptor.class, newDef ); TargetUsageItem tui = new TargetUsageItem(); tui.setName( "app or template name" ); tui.setVersion( "template qualifier (null for applications)" ); tui.setReferencing( true ); tui.setUsing( true ); writer = new StringWriter(); mapper.writeValue( writer, tui ); s = writer.toString(); convertToTypes( s, TargetUsageItem.class, newDef ); TargetAssociation ta = new TargetAssociation( "/vm-1", "VM", twd ); writer = new StringWriter(); mapper.writeValue( writer, ta ); s = writer.toString(); convertToTypes( s, TargetAssociation.class, newDef ); Preference pref = new Preference( "key", "value", PreferenceKeyCategory.AUTONOMIC ); writer = new StringWriter(); mapper.writeValue( writer, pref ); s = writer.toString(); convertToTypes( s, Preference.class, newDef ); ScheduledJob job = new ScheduledJob(); job.setAppName( "application name" ); job.setCmdName( "command name" ); job.setCron( "0 0 12 ? * WED" ); job.setJobId( "job-id" ); job.setJobName( "job name" ); writer = new StringWriter(); mapper.writeValue( writer, job ); s = writer.toString(); convertToTypes( s, ScheduledJob.class, newDef ); return newDef; }  }
UpdateSwaggerJson { public JsonObject prepareNewDefinitions() throws IOException { ObjectMapper mapper = JSonBindingUtils.createObjectMapper(); StringWriter writer = new StringWriter(); JsonObject newDef = new JsonObject(); Application app = newTestApplication(); app.bindWithApplication( "externalExportPrefix1", "application 1" ); app.bindWithApplication( "externalExportPrefix1", "application 2" ); app.bindWithApplication( "externalExportPrefix2", "application 3" ); app.setName( "My Application with special chàràcters" ); app.getTemplate().externalExports.put( "internalGraphVariable", "variableAlias" ); app.getTemplate().setExternalExportsPrefix( "externalExportPrefix" ); app.getTemplate().setDescription( "some description" ); writer = new StringWriter(); mapper.writeValue( writer, app ); String s = writer.toString(); convertToTypes( s, Application.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, app.getTemplate()); s = writer.toString(); convertToTypes( s, ApplicationTemplate.class, newDef ); Instance war = InstanceHelpers.findInstanceByPath( app, "/tomcat-vm/tomcat-server/hello-world" ); Objects.requireNonNull( war ); writer = new StringWriter(); mapper.writeValue( writer, war.getComponent()); s = writer.toString(); convertToTypes( s, Component.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, war ); s = writer.toString(); convertToTypes( s, Instance.class, newDef ); Diagnostic diag = new Diagnostic( "/vm1/server1" ); DependencyInformation di = new DependencyInformation( "facetOrComponentName", true, false ); diag.getDependenciesInformation().add( di ); writer = new StringWriter(); mapper.writeValue( writer, diag ); s = writer.toString(); convertToTypes( s, Diagnostic.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, di ); s = writer.toString(); convertToTypes( s, DependencyInformation.class, newDef ); TargetWrapperDescriptor twd = new TargetWrapperDescriptor(); twd.setId( "target-id" ); twd.setDescription( "some description" ); twd.setHandler( "iaas-ec2" ); twd.setName( "target name" ); twd.setDefault( true ); writer = new StringWriter(); mapper.writeValue( writer, twd ); s = writer.toString(); convertToTypes( s, TargetWrapperDescriptor.class, newDef ); TargetUsageItem tui = new TargetUsageItem(); tui.setName( "app or template name" ); tui.setVersion( "template qualifier (null for applications)" ); tui.setReferencing( true ); tui.setUsing( true ); writer = new StringWriter(); mapper.writeValue( writer, tui ); s = writer.toString(); convertToTypes( s, TargetUsageItem.class, newDef ); TargetAssociation ta = new TargetAssociation( "/vm-1", "VM", twd ); writer = new StringWriter(); mapper.writeValue( writer, ta ); s = writer.toString(); convertToTypes( s, TargetAssociation.class, newDef ); Preference pref = new Preference( "key", "value", PreferenceKeyCategory.AUTONOMIC ); writer = new StringWriter(); mapper.writeValue( writer, pref ); s = writer.toString(); convertToTypes( s, Preference.class, newDef ); ScheduledJob job = new ScheduledJob(); job.setAppName( "application name" ); job.setCmdName( "command name" ); job.setCron( "0 0 12 ? * WED" ); job.setJobId( "job-id" ); job.setJobName( "job name" ); writer = new StringWriter(); mapper.writeValue( writer, job ); s = writer.toString(); convertToTypes( s, ScheduledJob.class, newDef ); return newDef; }  static void main( String[] args ); void run( String[] args ); JsonObject prepareNewDefinitions(); void convertToTypes( String serialization, Class<?> clazz, JsonObject newDef ); static void convertToTypes( String serialization, String className, JsonObject newDef ); }
UpdateSwaggerJson { public JsonObject prepareNewDefinitions() throws IOException { ObjectMapper mapper = JSonBindingUtils.createObjectMapper(); StringWriter writer = new StringWriter(); JsonObject newDef = new JsonObject(); Application app = newTestApplication(); app.bindWithApplication( "externalExportPrefix1", "application 1" ); app.bindWithApplication( "externalExportPrefix1", "application 2" ); app.bindWithApplication( "externalExportPrefix2", "application 3" ); app.setName( "My Application with special chàràcters" ); app.getTemplate().externalExports.put( "internalGraphVariable", "variableAlias" ); app.getTemplate().setExternalExportsPrefix( "externalExportPrefix" ); app.getTemplate().setDescription( "some description" ); writer = new StringWriter(); mapper.writeValue( writer, app ); String s = writer.toString(); convertToTypes( s, Application.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, app.getTemplate()); s = writer.toString(); convertToTypes( s, ApplicationTemplate.class, newDef ); Instance war = InstanceHelpers.findInstanceByPath( app, "/tomcat-vm/tomcat-server/hello-world" ); Objects.requireNonNull( war ); writer = new StringWriter(); mapper.writeValue( writer, war.getComponent()); s = writer.toString(); convertToTypes( s, Component.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, war ); s = writer.toString(); convertToTypes( s, Instance.class, newDef ); Diagnostic diag = new Diagnostic( "/vm1/server1" ); DependencyInformation di = new DependencyInformation( "facetOrComponentName", true, false ); diag.getDependenciesInformation().add( di ); writer = new StringWriter(); mapper.writeValue( writer, diag ); s = writer.toString(); convertToTypes( s, Diagnostic.class, newDef ); writer = new StringWriter(); mapper.writeValue( writer, di ); s = writer.toString(); convertToTypes( s, DependencyInformation.class, newDef ); TargetWrapperDescriptor twd = new TargetWrapperDescriptor(); twd.setId( "target-id" ); twd.setDescription( "some description" ); twd.setHandler( "iaas-ec2" ); twd.setName( "target name" ); twd.setDefault( true ); writer = new StringWriter(); mapper.writeValue( writer, twd ); s = writer.toString(); convertToTypes( s, TargetWrapperDescriptor.class, newDef ); TargetUsageItem tui = new TargetUsageItem(); tui.setName( "app or template name" ); tui.setVersion( "template qualifier (null for applications)" ); tui.setReferencing( true ); tui.setUsing( true ); writer = new StringWriter(); mapper.writeValue( writer, tui ); s = writer.toString(); convertToTypes( s, TargetUsageItem.class, newDef ); TargetAssociation ta = new TargetAssociation( "/vm-1", "VM", twd ); writer = new StringWriter(); mapper.writeValue( writer, ta ); s = writer.toString(); convertToTypes( s, TargetAssociation.class, newDef ); Preference pref = new Preference( "key", "value", PreferenceKeyCategory.AUTONOMIC ); writer = new StringWriter(); mapper.writeValue( writer, pref ); s = writer.toString(); convertToTypes( s, Preference.class, newDef ); ScheduledJob job = new ScheduledJob(); job.setAppName( "application name" ); job.setCmdName( "command name" ); job.setCron( "0 0 12 ? * WED" ); job.setJobId( "job-id" ); job.setJobName( "job name" ); writer = new StringWriter(); mapper.writeValue( writer, job ); s = writer.toString(); convertToTypes( s, ScheduledJob.class, newDef ); return newDef; }  static void main( String[] args ); void run( String[] args ); JsonObject prepareNewDefinitions(); void convertToTypes( String serialization, Class<?> clazz, JsonObject newDef ); static void convertToTypes( String serialization, String className, JsonObject newDef );  }