### Question:
ProjectLoader { public Result loadProject(InputStream in) throws Exception { ProjectDefinitionBuilder b = new ProjectDefinitionBuilder(parser); b.loadDefinitions(in); return new Result(Collections.emptyList(), b.build()); } ProjectLoader(ImportManager importManager); Result loadProject(InputStream in); Result loadProject(Path workDir, ImportsNormalizer importsNormalizer); static boolean isConcordFileExists(Path repoPath);  }### Answer:
@Test public void testSimple() throws Exception { ProjectLoader loader = new ProjectLoader(mock(ImportManager.class)); URI uri = ClassLoader.getSystemResource("simple").toURI(); ProjectDefinition pd = loader.loadProject(Paths.get(uri), new NoopImportsNormalizer()) .getProjectDefinition(); assertNotNull(pd); assertNotNull(pd.getFlows().get("main")); assertNotNull(pd.getFlows().get("other")); assertNotNull(pd.getForms().get("myForm")); }
@Test(expected = YamlConverterException.class) public void testEmptyField() throws Exception { ProjectLoader loader = new ProjectLoader(mock(ImportManager.class)); URI uri = ClassLoader.getSystemResource("emptyField").toURI(); loader.loadProject(Paths.get(uri), new NoopImportsNormalizer()); }
@Test public void testDuplicateConfigurationSection() throws Exception { ProjectLoader loader = new ProjectLoader(mock(ImportManager.class)); URI uri = ClassLoader.getSystemResource("duplicateConfiguration").toURI(); try { loader.loadProject(Paths.get(uri), new NoopImportsNormalizer()); fail("exception expected"); } catch (YamlParserException e) { assertTrue(e.getMessage().contains("Duplicate field 'configuration'")); } }
@Test public void testDuplicateConfigurationVariable() throws Exception { ProjectLoader loader = new ProjectLoader(mock(ImportManager.class)); URI uri = ClassLoader.getSystemResource("duplicateConfigurationVariable").toURI(); try { loader.loadProject(Paths.get(uri), new NoopImportsNormalizer()); fail("exception expected"); } catch (YamlParserException e) { assertTrue(e.getMessage().contains("Duplicate field 'x'")); } }
@Test public void testComplex() throws Exception { ProjectLoader loader = new ProjectLoader(mock(ImportManager.class)); URI uri = ClassLoader.getSystemResource("complex").toURI(); ProjectDefinition pd = loader.loadProject(Paths.get(uri), new NoopImportsNormalizer()).getProjectDefinition(); assertNotNull(pd); assertNotNull(pd.getTriggers()); assertEquals(4, pd.getTriggers().size()); assertEquals("manual", pd.getTriggers().get(3).getName()); assertEquals("integration", pd.getTriggers().get(3).getEntryPoint()); assertEquals("Run Integration Tests", pd.getTriggers().get(3).getCfg().get("name")); assertNotNull(pd.getImports()); assertEquals(3, pd.getImports().items().size()); assertEquals("git", pd.getImports().items().get(0).type()); assertNotNull(pd.getResources()); assertEquals(1, pd.getResources().getDefinitionPaths().size()); assertEquals("myFlows", pd.getResources().getDefinitionPaths().get(0)); assertEquals(1, pd.getResources().getDisabledDirs().size()); assertEquals("processes", pd.getResources().getDisabledDirs().get(0)); assertEquals(1, pd.getResources().getProfilesPaths().size()); assertEquals("myProfiles", pd.getResources().getProfilesPaths().get(0)); }
@Test @SuppressWarnings("unchecked") public void testMultiProjectFiles() throws Exception { ProjectLoader loader = new ProjectLoader(mock(ImportManager.class)); URI uri = ClassLoader.getSystemResource("multiProjectFile").toURI(); ProjectDefinition pd = loader.loadProject(Paths.get(uri), new NoopImportsNormalizer()).getProjectDefinition(); assertNotNull(pd); assertNotNull(pd.getFlows().get("default")); assertNotNull(pd.getForms().get("myForm")); assertFalse(pd.getTriggers().isEmpty()); Map<String, Object> cfg = pd.getConfiguration(); assertNotNull(cfg); assertEquals("ttt", ((Map<String, Object>) cfg.get("arguments")).get("abc")); assertEquals("234", ((Map<String, Object>) ((Map<String, Object>) cfg.get("arguments")).get("nested")).get("value")); }