@Test public void testApplicationWithMissingGraph() throws Exception { File dir = this.folder.newFolder(); Assert.assertTrue( new File( dir, Constants.PROJECT_DIR_DESC ).mkdir()); Assert.assertTrue( new File( dir, Constants.PROJECT_DIR_GRAPH ).mkdir()); Assert.assertTrue( new File( dir, Constants.PROJECT_DIR_INSTANCES ).mkdir()); Assert.assertTrue( new File( dir, Constants.PROJECT_DIR_INSTANCES + "/model.instances" ).createNewFile()); ApplicationTemplateDescriptor desc = new ApplicationTemplateDescriptor(); desc.setName( "app name" ); desc.setVersion( "3.0" ); desc.setInstanceEntryPoint( "model.instances" ); desc.setDslId( "roboconf-1.0" ); ApplicationTemplateDescriptor.save( new File( dir, Constants.PROJECT_DIR_DESC + "/" + Constants.PROJECT_FILE_DESCRIPTOR ), desc ); Iterator<RoboconfError> it = RuntimeModelIo.loadApplicationFlexibly( dir ).loadErrors.iterator(); Assert.assertEquals( ErrorCode.RM_MISSING_APPLICATION_GEP, it.next().getErrorCode()); Assert.assertEquals( ErrorCode.CO_GRAPH_COULD_NOT_BE_BUILT, it.next().getErrorCode()); }
public static ApplicationLoadResult loadApplicationFlexibly( File projectDirectory ) { File descDirectory = new File( projectDirectory, Constants.PROJECT_DIR_DESC ); ApplicationLoadResult result; if( descDirectory.exists()) { result = loadApplication( projectDirectory ); } else { ApplicationTemplateDescriptor appDescriptor = new ApplicationTemplateDescriptor(); appDescriptor.setName( Constants.GENERATED ); appDescriptor.setDslId( Constants.GENERATED ); appDescriptor.setVersion( Constants.GENERATED ); ApplicationLoadResult alr = new ApplicationLoadResult(); alr.applicationTemplate = new ApplicationTemplate( Constants.GENERATED ).dslId( Constants.GENERATED ).version( Constants.GENERATED ); File graphDirectory = new File( projectDirectory, Constants.PROJECT_DIR_GRAPH ); File[] graphFiles = graphDirectory.listFiles( new GraphFileFilter()); if( graphFiles != null && graphFiles.length > 0 ) appDescriptor.setGraphEntryPoint( graphFiles[ 0 ].getName()); result = loadApplication( projectDirectory, appDescriptor, alr ); } return result; }
RuntimeModelIo { public static ApplicationLoadResult loadApplicationFlexibly( File projectDirectory ) { File descDirectory = new File( projectDirectory, Constants.PROJECT_DIR_DESC ); ApplicationLoadResult result; if( descDirectory.exists()) { result = loadApplication( projectDirectory ); } else { ApplicationTemplateDescriptor appDescriptor = new ApplicationTemplateDescriptor(); appDescriptor.setName( Constants.GENERATED ); appDescriptor.setDslId( Constants.GENERATED ); appDescriptor.setVersion( Constants.GENERATED ); ApplicationLoadResult alr = new ApplicationLoadResult(); alr.applicationTemplate = new ApplicationTemplate( Constants.GENERATED ).dslId( Constants.GENERATED ).version( Constants.GENERATED ); File graphDirectory = new File( projectDirectory, Constants.PROJECT_DIR_GRAPH ); File[] graphFiles = graphDirectory.listFiles( new GraphFileFilter()); if( graphFiles != null && graphFiles.length > 0 ) appDescriptor.setGraphEntryPoint( graphFiles[ 0 ].getName()); result = loadApplication( projectDirectory, appDescriptor, alr ); } return result; } }
RuntimeModelIo { public static ApplicationLoadResult loadApplicationFlexibly( File projectDirectory ) { File descDirectory = new File( projectDirectory, Constants.PROJECT_DIR_DESC ); ApplicationLoadResult result; if( descDirectory.exists()) { result = loadApplication( projectDirectory ); } else { ApplicationTemplateDescriptor appDescriptor = new ApplicationTemplateDescriptor(); appDescriptor.setName( Constants.GENERATED ); appDescriptor.setDslId( Constants.GENERATED ); appDescriptor.setVersion( Constants.GENERATED ); ApplicationLoadResult alr = new ApplicationLoadResult(); alr.applicationTemplate = new ApplicationTemplate( Constants.GENERATED ).dslId( Constants.GENERATED ).version( Constants.GENERATED ); File graphDirectory = new File( projectDirectory, Constants.PROJECT_DIR_GRAPH ); File[] graphFiles = graphDirectory.listFiles( new GraphFileFilter()); if( graphFiles != null && graphFiles.length > 0 ) appDescriptor.setGraphEntryPoint( graphFiles[ 0 ].getName()); result = loadApplication( projectDirectory, appDescriptor, alr ); } return result; } private  RuntimeModelIo(); }
RuntimeModelIo { public static ApplicationLoadResult loadApplicationFlexibly( File projectDirectory ) { File descDirectory = new File( projectDirectory, Constants.PROJECT_DIR_DESC ); ApplicationLoadResult result; if( descDirectory.exists()) { result = loadApplication( projectDirectory ); } else { ApplicationTemplateDescriptor appDescriptor = new ApplicationTemplateDescriptor(); appDescriptor.setName( Constants.GENERATED ); appDescriptor.setDslId( Constants.GENERATED ); appDescriptor.setVersion( Constants.GENERATED ); ApplicationLoadResult alr = new ApplicationLoadResult(); alr.applicationTemplate = new ApplicationTemplate( Constants.GENERATED ).dslId( Constants.GENERATED ).version( Constants.GENERATED ); File graphDirectory = new File( projectDirectory, Constants.PROJECT_DIR_GRAPH ); File[] graphFiles = graphDirectory.listFiles( new GraphFileFilter()); if( graphFiles != null && graphFiles.length > 0 ) appDescriptor.setGraphEntryPoint( graphFiles[ 0 ].getName()); result = loadApplication( projectDirectory, appDescriptor, alr ); } return result; } 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 ); }
RuntimeModelIo { public static ApplicationLoadResult loadApplicationFlexibly( File projectDirectory ) { File descDirectory = new File( projectDirectory, Constants.PROJECT_DIR_DESC ); ApplicationLoadResult result; if( descDirectory.exists()) { result = loadApplication( projectDirectory ); } else { ApplicationTemplateDescriptor appDescriptor = new ApplicationTemplateDescriptor(); appDescriptor.setName( Constants.GENERATED ); appDescriptor.setDslId( Constants.GENERATED ); appDescriptor.setVersion( Constants.GENERATED ); ApplicationLoadResult alr = new ApplicationLoadResult(); alr.applicationTemplate = new ApplicationTemplate( Constants.GENERATED ).dslId( Constants.GENERATED ).version( Constants.GENERATED ); File graphDirectory = new File( projectDirectory, Constants.PROJECT_DIR_GRAPH ); File[] graphFiles = graphDirectory.listFiles( new GraphFileFilter()); if( graphFiles != null && graphFiles.length > 0 ) appDescriptor.setGraphEntryPoint( graphFiles[ 0 ].getName()); result = loadApplication( projectDirectory, appDescriptor, alr ); } return result; } 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 );  }