ArchiveImageLoader { public void importImages(Path archiveFile, ArchiveRoot archiveRoot, List<ParsingError> parsingErrors) { importImages(archiveFile, archiveRoot.getNodeTypes(), parsingErrors); importImages(archiveFile, archiveRoot.getRelationshipTypes(), parsingErrors); importImages(archiveFile, archiveRoot.getCapabilityTypes(), parsingErrors); importImages(archiveFile, archiveRoot.getArtifactTypes(), parsingErrors); importImages(archiveFile, archiveRoot.getPolicyTypes(), parsingErrors); importImages(archiveFile, archiveRoot.getArchive().getTags(), parsingErrors); if (archiveRoot.getArchive().isHasTopology()) { importImages(archiveFile, archiveRoot.getTopology().getTags(), parsingErrors); } }  void importImages(Path archiveFile, ArchiveRoot archiveRoot, List<ParsingError> parsingErrors); static Tag getIconTag(List<Tag> tags);  }
@Test public void importToscaElementImages() throws IOException, ParsingException { Path csarFileForTesting = Paths.get(CSAR_OUTPUT_FOLDER.toString(), tmpArchiveName); FileUtil.zip(PATH_TOSCA_BASE_TYPES, csarFileForTesting); Path imagesPath = Paths.get("target/alien/images"); if (!Files.exists(imagesPath)) { Files.createDirectories(imagesPath); } ParsingResult<ArchiveRoot> result = parser.parse(csarFileForTesting, AlienConstants.GLOBAL_WORKSPACE_ID); imageLoader.importImages(csarFileForTesting, result.getResult(), result.getContext().getParsingErrors()); Assert.assertFalse(result.hasError(ParsingErrorLevel.ERROR)); Assert.assertFalse(result.hasError(ParsingErrorLevel.WARNING)); checkImages(result.getResult().getNodeTypes()); }
@Test public void importToscaElementWithBadImageUri() throws IOException, ParsingException { Path csarFileForTesting = Paths.get(CSAR_OUTPUT_FOLDER.toString(), tmpArchiveNameWithError); FileUtil.zip(PATH_TOSCA_BASE_TYPES_ERROR, csarFileForTesting); ParsingResult<ArchiveRoot> result = parser.parse(csarFileForTesting, AlienConstants.GLOBAL_WORKSPACE_ID); imageLoader.importImages(csarFileForTesting, result.getResult(), result.getContext().getParsingErrors()); Assert.assertFalse(result.hasError(ParsingErrorLevel.ERROR)); Assert.assertTrue(result.hasError(ParsingErrorLevel.WARNING)); }