use of org.guvnor.common.services.project.model.ProjectImports in project kie-wb-common by kiegroup.
the class ProjectScreenModelLoaderTest method testImports.
@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());
}
use of org.guvnor.common.services.project.model.ProjectImports in project kie-wb-common by kiegroup.
the class ProjectScreenServiceImplTest method setup.
@Before
public void setup() {
projectImports = new ProjectImports();
moduleRepositories = new ModuleRepositories();
loader = new ProjectScreenModelLoader(moduleService, pomService, metadataService, kModuleService, importsService, repositoriesService, allowListService, projectService) {
@Override
protected boolean fileExists(final Path path) {
return true;
}
};
saver = new ProjectScreenModelSaver(pomService, kModuleService, importsService, repositoriesService, allowListService, ioService, moduleService, repositoryResolver, commentedOptionFactory, pomModelCache);
service = new ProjectScreenServiceImpl(projectService, repositoryService, moduleService, loader, saver, repositoryCopier, pomService, metadataService, newProjectEvent);
when(module.getKModuleXMLPath()).thenReturn(pathToKieModule);
when(module.getImportsPath()).thenReturn(pathToModuleImports);
when(module.getRepositoriesPath()).thenReturn(pathToModuleRepositories);
when(module.getPom()).thenReturn(pom);
when(pathToPom.toURI()).thenReturn("default://pom.xml");
when(pomService.load(eq(pathToPom))).thenReturn(pom);
when(kModuleService.load(eq(pathToKieModule))).thenReturn(kmodule);
when(importsService.load(eq(pathToModuleImports))).thenReturn(projectImports);
when(repositoriesService.load(eq(pathToModuleRepositories))).thenReturn(moduleRepositories);
when(moduleService.resolveModule(eq(pathToPom))).thenReturn(module);
when(metadataService.getMetadata(eq(pathToPom))).thenReturn(pomMetaData);
when(metadataService.getMetadata(eq(pathToKieModule))).thenReturn(kmoduleMetaData);
when(metadataService.getMetadata(eq(pathToModuleImports))).thenReturn(projectImportsMetaData);
when(projectService.resolveProject((Path) any())).thenReturn(spy(new WorkspaceProject(mock(OrganizationalUnit.class), new GitRepository("alias", mock(Space.class), emptyList()), mock(Branch.class), mock(Module.class))));
}
use of org.guvnor.common.services.project.model.ProjectImports in project kie-wb-common by kiegroup.
the class ProjectScreenModelSaverTest method testImportsSave.
@Test
public void testImportsSave() throws Exception {
final ProjectScreenModel model = new ProjectScreenModel();
final ProjectImports projectImports = new ProjectImports();
model.setProjectImports(projectImports);
final Path pathToImports = mock(Path.class);
model.setPathToImports(pathToImports);
final Metadata metadata = new Metadata();
model.setProjectImportsMetaData(metadata);
saver.save(pathToPom, model, DeploymentMode.FORCED, "message imports");
verify(importsService).save(eq(pathToImports), eq(projectImports), eq(metadata), eq("message imports"));
}
use of org.guvnor.common.services.project.model.ProjectImports in project kie-wb-common by kiegroup.
the class ProjectScreenModelTest method testHashCode.
@Test
public void testHashCode() {
final ProjectScreenModel model = new ProjectScreenModel();
model.setPOM(new POM("test", "test", "url", new GAV("groupID", "artifactID", "version")));
final MavenRepository repository = new MavenRepository();
repository.setId("guvnor-m2-repo");
repository.setName("Guvnor M2 Repo");
repository.setUrl("http://localhost/maven2/");
model.getPOM().addRepository(repository);
model.setPOMMetaData(new Metadata());
model.setKModule(new KModuleModel());
model.setKModuleMetaData(new Metadata());
model.setProjectTagsMetaData(new Metadata());
model.setProjectImports(new ProjectImports());
model.setProjectImportsMetaData(new Metadata());
final int hashCode1 = model.hashCode();
assertTrue(hashCode1 <= Integer.MAX_VALUE);
assertTrue(hashCode1 >= Integer.MIN_VALUE);
model.getProjectImports().getImports().addImport(new Import("java.lang.List"));
final int hashCode2 = model.hashCode();
assertTrue(hashCode2 <= Integer.MAX_VALUE);
assertTrue(hashCode2 >= Integer.MIN_VALUE);
assertNotEquals(hashCode1, hashCode2);
}
use of org.guvnor.common.services.project.model.ProjectImports in project kie-wb-common by kiegroup.
the class ExternalDataObjectsPresenterTest method testSetup.
@Test
public void testSetup() {
final ProjectScreenModel model = mock(ProjectScreenModel.class);
doReturn(new ProjectImports()).when(model).getProjectImports();
externalDataObjectsPresenter.setup(model).catch_(i -> {
Assert.fail("Promise should've been resolved!");
return promises.resolve();
});
verify(view).init(eq(externalDataObjectsPresenter));
verify(itemPresenters).setup(any(), any(), any());
}
Aggregations