use of org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorEditorContent in project kie-wb-common by kiegroup.
the class PersistenceDescriptorEditorServiceImpl method loadContent.
@Override
public PersistenceDescriptorEditorContent loadContent(Path path, boolean createIfNotExists) {
PersistenceDescriptorEditorContent content;
if (createIfNotExists) {
// was called manually form the project editor
Pair<Path, Boolean> createIfNotExistsResult = createIfNotExists(path);
content = loadContent(createIfNotExistsResult.getK1());
content.setPath(createIfNotExistsResult.getK1());
content.setCreated(createIfNotExistsResult.getK2());
} else {
content = loadContent(path);
content.setPath(path);
content.setCreated(false);
}
return content;
}
use of org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorEditorContent in project kie-wb-common by kiegroup.
the class PersistencePresenterTest method testSetup.
@Test
public void testSetup() {
final PersistenceDescriptorEditorContent model = spy(newPersistenceDescriptorEditorContent());
doReturn(model).when(editorService).loadContent(any(), anyBoolean());
persistencePresenter.setup(mock(ProjectScreenModel.class)).catch_(i -> {
Assert.fail("Promise should've been resolved!");
return promises.resolve();
});
verify(view).init(eq(persistencePresenter));
verify(editorService).loadContent(any(), anyBoolean());
verify(newPropertyModal).setup(any(), any(), any());
verify(propertiesListPresenter).setup(any(), any(), any());
verify(newPersistableDataObjectModal).setup(any(), any());
verify(persistableDataObjectsListPresenter).setup(any(), any(), any());
verify(view).setPersistenceUnit(model.getDescriptorModel().getPersistenceUnit().getName());
verify(view).setPersistenceProvider(model.getDescriptorModel().getPersistenceUnit().getProvider());
verify(view).setDataSource(eq(model.getDescriptorModel().getPersistenceUnit().getJtaDataSource()));
}
use of org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorEditorContent in project kie-wb-common by kiegroup.
the class PersistenceDescriptorEditorServiceImplTest method testSaveAndRename.
@Test
public void testSaveAndRename() throws Exception {
final Path path = mock(Path.class);
final Path expectedPath = mock(Path.class);
final Metadata metadata = mock(Metadata.class);
final PersistenceDescriptorEditorContent content = mock(PersistenceDescriptorEditorContent.class);
final String newName = "newName";
final String comment = "comment";
doReturn(expectedPath).when(saveAndRenameService).saveAndRename(path, newName, metadata, content, comment);
final Path actualPath = service.saveAndRename(path, newName, metadata, content, comment);
verify(saveAndRenameService).saveAndRename(path, newName, metadata, content, comment);
assertEquals(expectedPath, actualPath);
}
Aggregations