### Question:
ProjectScreenModelLoader { public ProjectScreenModel load(final Path pathToPom) { return new Loader(pathToPom).load(); } ProjectScreenModelLoader(); @Inject  ProjectScreenModelLoader(final KieModuleService moduleService,
                                    final POMService pomService,
                                    final MetadataService metadataService,
                                    final KModuleService kModuleService,
                                    final ProjectImportsService importsService,
                                    final ModuleRepositoriesService repositoriesService,
                                    final PackageNameWhiteListService whiteListService,
                                    final WorkspaceProjectService workspaceProjectService); ProjectScreenModel load(final Path pathToPom);  }### Answer:
@Test public void testLoadPom() throws Exception { final POM pom = new POM(); when(pomService.load(pathToPom)).thenReturn(pom); final Metadata metadata = new Metadata(); when(metadataService.getMetadata(pathToPom)).thenReturn(metadata); ProjectScreenModel model = loader.load(pathToPom); assertEquals(pathToPom, model.getPathToPOM()); assertEquals(pom, model.getPOM()); assertEquals(metadata, model.getPOMMetaData()); }
@Test public void testKModule() throws Exception { final KModuleModel kModuleModel = new KModuleModel(); when(kModuleService.load(kmoduleXMLPath)).thenReturn(kModuleModel); final Metadata metadata = new Metadata(); when(metadataService.getMetadata(kmoduleXMLPath)).thenReturn(metadata); ProjectScreenModel model = loader.load(pathToPom); assertEquals(kmoduleXMLPath, model.getPathToKModule()); assertEquals(kModuleModel, model.getKModule()); assertEquals(metadata, model.getKModuleMetaData()); }
@Test public void testImports() throws Exception { final ProjectImports projectImports = new ProjectImports(); when(projectImportsService.load(importsPath)).thenReturn(projectImports); final Metadata metadata = new Metadata(); when(metadataService.getMetadata(importsPath)).thenReturn(metadata); ProjectScreenModel model = loader.load(pathToPom); assertEquals(importsPath, model.getPathToImports()); assertEquals(projectImports, model.getProjectImports()); assertEquals(metadata, model.getProjectImportsMetaData()); }
@Test public void testRepositories() throws Exception { final ModuleRepositories moduleRepositories = new ModuleRepositories(); when(moduleRepositoriesService.load(repositoriesPath)).thenReturn(moduleRepositories); ProjectScreenModel model = loader.load(pathToPom); assertEquals(repositoriesPath, model.getPathToRepositories()); assertEquals(moduleRepositories, model.getRepositories()); }
@Test public void testWhiteList() throws Exception { final WhiteList whiteList = new WhiteList(); when(whiteListService.load(packageNamesWhiteListPath)).thenReturn(whiteList); final Metadata metadata = new Metadata(); when(metadataService.getMetadata(packageNamesWhiteListPath)).thenReturn(metadata); ProjectScreenModel model = loader.load(pathToPom); assertEquals(packageNamesWhiteListPath, model.getPathToWhiteList()); assertEquals(whiteList, model.getWhiteList()); assertEquals(metadata, model.getWhiteListMetaData()); }
@Test public void testWhiteListNoMetadata() throws Exception { final WhiteList whiteList = new WhiteList(); testFileSystem.deleteFile(packageNamesWhiteListPath); when(whiteListService.load(packageNamesWhiteListPath)).thenReturn(whiteList); ProjectScreenModel model = loader.load(pathToPom); assertEquals(packageNamesWhiteListPath, model.getPathToWhiteList()); assertEquals(whiteList, model.getWhiteList()); assertNotNull(model.getWhiteListMetaData()); }
@Test public void testGitUrls() throws Exception { final ProjectScreenModel model = loader.load(pathToPom); assertEquals(1, model.getGitUrls().size()); assertEquals("git", model.getGitUrls().get(0).getProtocol()); assertEquals("git: model.getGitUrls().get(0).getUrl()); }