Search in sources :

Example 16 with CommentedOption

use of org.uberfire.java.nio.base.options.CommentedOption in project kie-wb-common by kiegroup.

the class ProjectScreenModelSaverTest method testBatchSave.

@Test
public void testBatchSave() throws Exception {
    final CommentedOption commentedOption = new CommentedOption("hello");
    when(commentedOptionFactory.makeCommentedOption("message")).thenReturn(commentedOption);
    saver.save(pathToPom, new ProjectScreenModel(), DeploymentMode.FORCED, "message");
    verify(ioService).startBatch(any(FileSystem.class), eq(commentedOption));
    verify(ioService).endBatch();
}
Also used : CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) TestFileSystem(org.guvnor.test.TestFileSystem) FileSystem(org.uberfire.java.nio.file.FileSystem) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test)

Example 17 with CommentedOption

use of org.uberfire.java.nio.base.options.CommentedOption in project kie-wb-common by kiegroup.

the class DataModelerServiceTest method testSaveSource.

private void testSaveSource(String newPackageName, String newFileName, DataObject dataObject) {
    Path dataObjectPath = PathFactory.newPath("TestDataObject", "file:///dataobjects/TestDataObject.java");
    Path srcPath = PathFactory.newPath("src", "file:///src");
    Package packageMock = mock(Package.class);
    when(packageMock.getPackageMainSrcPath()).thenReturn(srcPath);
    when(moduleService.resolvePackage(dataObjectPath)).thenReturn(packageMock);
    when(packageMock.getPackageName()).thenReturn("dataobjects");
    when(serviceHelper.ensurePackageStructure(Mockito.<Module>any(), Mockito.<String>any())).thenReturn(packageMock);
    DataModelerSaveHelper saveHelper = mock(DataModelerSaveHelper.class);
    List<DataModelerSaveHelper> saveHelpers = Arrays.asList(saveHelper);
    when(saveHelperInstance.iterator()).thenReturn(saveHelpers.iterator());
    dataModelerService.saveSource("Source", dataObjectPath, dataObject, mock(Metadata.class), "Commit message", newPackageName, newFileName);
    verify(ioService, times(1)).startBatch(Mockito.<FileSystem>any());
    if (newPackageName == null && newFileName == null) {
        verify(ioService, times(1)).write(Mockito.<org.uberfire.java.nio.file.Path>any(), Mockito.<String>any(), Mockito.<Map>any(), Mockito.<CommentedOption>any());
    } else if (newPackageName != null && newFileName != null) {
        verify(ioService, times(1)).write(Mockito.<org.uberfire.java.nio.file.Path>any(), Mockito.<String>any(), Mockito.<Map>any(), Mockito.<CommentedOption>any());
        verify(ioService, times(1)).move(Mockito.<org.uberfire.java.nio.file.Path>any(), Mockito.<org.uberfire.java.nio.file.Path>any(), Mockito.<CommentedOption>any());
    } else if (newPackageName != null) {
        verify(ioService, times(1)).write(Mockito.<org.uberfire.java.nio.file.Path>any(), Mockito.<String>any(), Mockito.<Map>any(), Mockito.<CommentedOption>any());
        verify(ioService, times(1)).move(Mockito.<org.uberfire.java.nio.file.Path>any(), Mockito.<org.uberfire.java.nio.file.Path>any(), Mockito.<CommentedOption>any());
    } else {
        verify(renameService, times(1)).rename(Mockito.<Path>any(), Mockito.<String>any(), Mockito.<String>any());
    }
    verify(saveHelper, times(1)).postProcess(Mockito.<Path>any(), Mockito.<Path>any());
    verify(ioService, times(1)).endBatch();
}
Also used : Path(org.uberfire.backend.vfs.Path) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) Package(org.guvnor.common.services.project.model.Package) DataModelerSaveHelper(org.kie.workbench.common.screens.datamodeller.backend.server.helper.DataModelerSaveHelper) Map(java.util.Map)

Example 18 with CommentedOption

use of org.uberfire.java.nio.base.options.CommentedOption in project drools-wb by kiegroup.

the class ScoreCardXLSServiceImplTest method testSessionInfoOnCreate.

@Test
public void testSessionInfoOnCreate() {
    service.create(path, inputstream, sessionId, comment);
    final CommentedOption commentedOption = commentedOptionArgumentCaptor.getValue();
    assertNotNull(commentedOption);
    assertEquals("user", commentedOption.getName());
    assertEquals("123", commentedOption.getSessionId());
}
Also used : CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) Test(org.junit.Test)

Example 19 with CommentedOption

use of org.uberfire.java.nio.base.options.CommentedOption in project drools-wb by kiegroup.

the class ScoreCardXLSServiceImplTest method testSessionInfoOnSave.

@Test
public void testSessionInfoOnSave() {
    service.save(path, inputstream, sessionId, comment);
    final CommentedOption commentedOption = commentedOptionArgumentCaptor.getValue();
    assertNotNull(commentedOption);
    assertEquals("user", commentedOption.getName());
    assertEquals("123", commentedOption.getSessionId());
}
Also used : CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) Test(org.junit.Test)

Aggregations

CommentedOption (org.uberfire.java.nio.base.options.CommentedOption)19 Test (org.junit.Test)11 Path (org.uberfire.backend.vfs.Path)8 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)6 HashMap (java.util.HashMap)3 Before (org.junit.Before)2 ProjectMetadata (org.kie.workbench.common.stunner.project.diagram.ProjectMetadata)2 Path (org.uberfire.java.nio.file.Path)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 URISyntaxException (java.net.URISyntaxException)1 Map (java.util.Map)1 Consumer (java.util.function.Consumer)1 Event (javax.enterprise.event.Event)1 IOUtils (org.apache.commons.io.IOUtils)1 DecisionTableParseException (org.drools.template.parser.DecisionTableParseException)1 DecisionTableXLSConversionService (org.drools.workbench.screens.dtablexls.service.DecisionTableXLSConversionService)1