use of org.kie.workbench.common.services.shared.kmodule.KModuleModel in project kie-wb-common by kiegroup.
the class KnowledgeBasesPresenterTest method testSetup.
@Test
public void testSetup() {
final ProjectScreenModel model = mock(ProjectScreenModel.class);
when(model.getKModule()).thenReturn(spy(new KModuleModel()));
when(model.getKModule().getKBases()).thenReturn(emptyMap());
knowledgeBasesPresenter.setup(model).catch_(i -> {
Assert.fail("Promise should've been resolved!");
return promises.resolve();
});
verify(view).init(eq(knowledgeBasesPresenter));
verify(knowledgeBaseListPresenter).setup(any(), any(), any());
}
use of org.kie.workbench.common.services.shared.kmodule.KModuleModel in project kie-wb-common by kiegroup.
the class KnowledgeBasesPresenterTest method testSave.
@Test
public void testSave() {
final KModuleModel kModuleModel = spy(new KModuleModel());
knowledgeBasesPresenter.kModuleModel = kModuleModel;
final Map<String, KBaseModel> kBasesMap = spy(new HashMap<>());
doReturn(kBasesMap).when(kModuleModel).getKBases();
knowledgeBasesPresenter.save("Test comment", null).catch_(i -> {
Assert.fail("Promise should've been resolved!");
return promises.resolve();
});
verify(kBasesMap).clear();
verify(kBasesMap).putAll(any());
}
use of org.kie.workbench.common.services.shared.kmodule.KModuleModel in project kie-wb-common by kiegroup.
the class ProjectScreenModelLoaderTest method testKModule.
@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());
}
use of org.kie.workbench.common.services.shared.kmodule.KModuleModel 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.kie.workbench.common.services.shared.kmodule.KModuleModel in project kie-wb-common by kiegroup.
the class KSessionSelectorTest method setUp.
@Before
public void setUp() throws Exception {
kieModule = spy(new KieModule());
when(kieModule.getKModuleXMLPath()).thenReturn(kmodulePath);
kModule = new KModuleModel();
kModule.getKBases().put("kbase1", getKBase("kbase1", "ksession1"));
kModule.getKBases().put("kbase2", getKBase("kbase2", "ksession2", "ksession3"));
kModule.getKBases().put("kbase3", getKBase("kbase3"));
view = mock(KSessionSelectorView.class);
when(kieModuleService.resolveModule(path)).thenReturn(kieModule);
when(kModuleService.load(kmodulePath)).thenReturn(kModule);
selector = new KSessionSelector(view, new CallerMock<>(kieModuleService), new CallerMock<>(kModuleService));
}
Aggregations