Search in sources :

Example 6 with PersistenceDescriptorEditorContent

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;
}
Also used : Path(org.uberfire.backend.vfs.Path) PersistenceDescriptorEditorContent(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorEditorContent)

Example 7 with PersistenceDescriptorEditorContent

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()));
}
Also used : PersistenceDescriptorEditorContent(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorEditorContent) Test(org.junit.Test)

Example 8 with PersistenceDescriptorEditorContent

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);
}
Also used : Path(org.uberfire.backend.vfs.Path) PersistenceDescriptorEditorContent(org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorEditorContent) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) Test(org.junit.Test)

Aggregations

PersistenceDescriptorEditorContent (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorEditorContent)8 Test (org.junit.Test)5 PersistenceDescriptorModel (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceDescriptorModel)2 Path (org.uberfire.backend.vfs.Path)2 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)1 Overview (org.guvnor.common.services.shared.metadata.model.Overview)1 PersistenceUnitModel (org.kie.workbench.common.screens.datamodeller.model.persistence.PersistenceUnitModel)1