@Test public void testParsingWithInvalidRecipeProject_2() throws Exception { File dir = TestUtils.findTestFile( "/reusable.recipe.with.errors.2" ); Assert.assertTrue( dir.exists()); ApplicationLoadResult alr = RuntimeModelIo.loadApplicationFlexibly( dir ); RoboconfErrorHelpers.filterErrorsForRecipes( alr ); List<RoboconfError> errors = new ArrayList<>( alr.getLoadErrors()); Assert.assertEquals( 2, errors.size()); Assert.assertEquals( ErrorCode.RM_COMPONENT_IMPORTS_EXPORTS, errors.get( 0 ).getErrorCode()); Assert.assertEquals( ErrorCode.PROJ_NO_RESOURCE_DIRECTORY, errors.get( 1 ).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 );  }