RuntimeModelIo { public static void writeInstances( File targetFile, Collection<Instance> rootInstances ) throws IOException { FileDefinition def = new FromInstances().buildFileDefinition( rootInstances, targetFile, false, true ); ParsingModelIo.saveRelationsFile( def, false, "\n" ); } private  RuntimeModelIo(); static ApplicationLoadResult loadApplication( File projectDirectory ); static ApplicationLoadResult loadApplicationFlexibly( File projectDirectory ); static Graphs loadGraph( File graphFile, File graphDirectory, ApplicationLoadResult alr ); static InstancesLoadResult loadInstances( File instancesFile, File rootDirectory, Graphs graph, String applicationName ); static void writeInstances( File targetFile, Collection<Instance> rootInstances );  }
@Test public void testWriteInstances_empty() throws Exception { File targetFile = this.folder.newFile(); RuntimeModelIo.writeInstances( targetFile, new ArrayList<Instance>( 0 )); Assert.assertTrue( targetFile.exists()); Assert.assertEquals( 0, targetFile.length()); }
@Test public void testWriteInstances_notEmpty() throws Exception { Component component = new Component( "comp" ); Instance instance = new Instance( "inst" ).component( component ).status( InstanceStatus.DEPLOYING ).channel( "c" ); instance.overriddenExports.put( "check", "true" ); instance.data.put( "something", "else" ); File targetFile = this.folder.newFile(); RuntimeModelIo.writeInstances( targetFile, Arrays.asList( instance )); Assert.assertTrue( targetFile.exists()); Assert.assertTrue( 0 < targetFile.length()); }