use of org.uberfire.java.nio.base.version.VersionRecord in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorServiceImplTest method checkSaveAndUpdateGraphEntries.
@Test
@SuppressWarnings("unchecked")
public void checkSaveAndUpdateGraphEntries() {
// Setup Decision Table
final Path path = mock(Path.class);
final GuidedDecisionTable52 model = new GuidedDecisionTable52();
final Metadata metadata = mock(Metadata.class);
final String comment = "comment";
final String headPathUri = "default://project/src/main/resources/mypackage/dtable.gdst";
final String versionPathUri = "default://0123456789@project/src/main/resources/mypackage/dtable.gdst";
when(path.toURI()).thenReturn(headPathUri);
when(path.getFileName()).thenReturn("dtable.gdst");
// Setup Decision Table versions
final List<VersionRecord> versions = new ArrayList<>();
versions.add(new PortableVersionRecord("0123456789", "manstis", "manstis@email.com", "comment", Calendar.getInstance().getTime(), versionPathUri));
when(versionRecordService.load(any(org.uberfire.java.nio.file.Path.class))).thenReturn(versions);
// Setup Decision Table Graph
final URI dtGraphPathUri = URI.create("default://project/src/main/resources/mypackage/graph1.gdst-set");
final org.uberfire.java.nio.file.Path dtGraphPath = mock(org.uberfire.java.nio.file.Path.class);
when(dtGraphPath.toUri()).thenReturn(dtGraphPathUri);
when(dtGraphPath.getFileName()).thenReturn(dtGraphPath);
when(dtGraphPath.getFileSystem()).thenReturn(fileSystem);
final List<org.uberfire.java.nio.file.Path> dtGraphPaths = new ArrayList<>();
dtGraphPaths.add(dtGraphPath);
when(ioService.newDirectoryStream(any(org.uberfire.java.nio.file.Path.class), any(FileExtensionFilter.class))).thenReturn(new MockDirectoryStream(dtGraphPaths));
final GuidedDecisionTableEditorGraphModel dtGraphModel = new GuidedDecisionTableEditorGraphModel();
dtGraphModel.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(path, path));
when(dtableGraphService.load(any(Path.class))).thenReturn(dtGraphModel);
// Test save
service.saveAndUpdateGraphEntries(path, model, metadata, comment);
verify(ioService, times(1)).startBatch(any(FileSystem.class));
verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any(Map.class), any(CommentedOption.class));
verify(ioService, times(1)).endBatch();
assertEquals("mypackage", model.getPackageName());
assertEquals(1, dtGraphModel.getEntries().size());
assertEquals(versions.get(0).uri(), dtGraphModel.getEntries().iterator().next().getPathVersion().toURI());
}
use of org.uberfire.java.nio.base.version.VersionRecord in project kie-wb-common by kiegroup.
the class ContributorsManager method buildDataSet.
@Override
public DataSet buildDataSet(Map<String, String> params) {
final DataSetBuilder dsBuilder = DataSetFactory.newDataSetBuilder();
for (final DataColumnDef columnDef : dataSetdef.getColumns()) {
dsBuilder.column(columnDef.getId(), columnDef.getColumnType());
}
final Collection<OrganizationalUnit> orgUnitList = organizationalUnitService.getOrganizationalUnits();
for (final OrganizationalUnit orgUnit : orgUnitList) {
final String org = orgUnit.getName();
final Collection<WorkspaceProject> projects = projectService.getAllWorkspaceProjects(orgUnit);
if (projects.isEmpty()) {
// org
dsBuilder.row(// org
org, // repo
null, // project
null, // author
null, // message
"Empty organizational unit", // date
null);
} else {
for (final WorkspaceProject project : projects) {
final String repoAlias = project.getRepository().getAlias();
final String projectName = project.getName();
org.uberfire.backend.vfs.Path rootPath = project.getRootPath();
final Path projectRoot = Paths.convert(rootPath);
final List<VersionRecord> recordList = recordService.loadVersionRecords(projectRoot);
if (recordList.isEmpty()) {
// org
dsBuilder.row(// org
org, // repo
repoAlias, // project
null, // author
null, // mesage
"Empty project", // date
null);
} else {
for (VersionRecord record : recordList) {
String alias = record.author();
String author = authorMappings.getProperty(alias);
author = author == null ? alias : author;
String msg = record.comment();
Date date = record.date();
dsBuilder.row(org, repoAlias, projectName, author, msg, date);
}
}
}
}
}
DataSet dataSet = dsBuilder.buildDataSet();
dataSet.setUUID(GIT_CONTRIB);
return dataSet;
}
use of org.uberfire.java.nio.base.version.VersionRecord in project kie-wb-common by kiegroup.
the class ContributorsManagerTest method setUp.
@Before
public void setUp() throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
List<VersionRecord> repositoryHistory1 = new ArrayList<>();
repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0441b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/01/2017"), "default://3da0442b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0443b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/02/2017"), "default://3da0441b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/03/2017"), "default://3da0442b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("02/03/2017"), "default://3da04471@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/04/2017"), "default://3da0442b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/05/2017"), "default://3da0443b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/02/2017"), "default://3da0444b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0443b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("01/06/2017"), "default://3da0447b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/06/2017"), "default://3da0445b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/06/2017"), "default://3da0457b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0441b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/03/2017"), "default://3da0442b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/04/2017"), "default://3da0442b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/06/2017"), "default://3da0443b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/0/2017"), "default://3da04474@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/08/2016"), "default://3da0445b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/08/2016"), "default://3da0446b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/09/2016"), "default://3da0447b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/10/2016"), "default://3da0445b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/11/2016"), "default://3da0444b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/11/2016"), "default://3da0442b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/12/2016"), "default://3da0442b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("01/12/2016"), "default://3da0441b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/04/2017"), "default://3da0444b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/05/2017"), "default://3da0444b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/02/2017"), "default://3da0443b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0442b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0441b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/01/2017"), "default://3da0442b@project1/file"));
repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0443b@project1/file"));
List<VersionRecord> repositoryHistory2 = new ArrayList<>();
repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/02/2017"), "default://3da0441b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/03/2017"), "default://3da0442b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("02/03/2017"), "default://3da04471@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/04/2017"), "default://3da0442b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/05/2017"), "default://3da0443b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/02/2017"), "default://3da0444b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0443b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("01/06/2017"), "default://3da0447b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/06/2017"), "default://3da0445b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/06/2017"), "default://3da0457b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0441b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/03/2017"), "default://3da0442b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/04/2017"), "default://3da0442b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/06/2017"), "default://3da0443b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/0/2017"), "default://3da04474@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/08/2016"), "default://3da0445b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/08/2016"), "default://3da0446b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/09/2016"), "default://3da0447b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/10/2016"), "default://3da0445b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/11/2016"), "default://3da0444b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/11/2016"), "default://3da0442b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/12/2016"), "default://3da0442b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("01/12/2016"), "default://3da0441b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0441b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/02/2017"), "default://3da0442b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/03/2017"), "default://3da0443b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("02/03/2017"), "default://3da0444b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/04/2017"), "default://3da0444b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/05/2017"), "default://3da0444b@project2/file"));
repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/02/2017"), "default://3da0443b@project2/file"));
System.out.println("SUM = " + (repositoryHistory1.size() + repositoryHistory2.size()));
final Repository repo1 = makeRepository("testRepo1");
final Repository repo2 = makeRepository("testRepo2");
final OrganizationalUnit org1 = makeOrganizationalUnit("test1", Arrays.asList(repo1, repo2));
when(organizationalUnitService.getOrganizationalUnits()).thenReturn(Arrays.asList(org1));
final Set<WorkspaceProject> projects = new HashSet<>();
projects.add(makeProject(repo1, org1, "project1"));
projects.add(makeProject(repo2, org1, "project2"));
when(projectService.getAllWorkspaceProjects(eq(org1))).thenReturn(projects);
when(recordService.loadVersionRecords(any())).thenReturn(repositoryHistory1).thenReturn(repositoryHistory2);
}
use of org.uberfire.java.nio.base.version.VersionRecord in project kie-wb-common by kiegroup.
the class KieMultipleDocumentEditorTest method testVersionRecordManagerSelectionChange.
@Test
@SuppressWarnings("unchecked")
public void testVersionRecordManagerSelectionChange() {
final TestDocument document = createTestDocument();
final ObservablePath path = document.getLatestPath();
registerDocument(document);
activateDocument(document);
final ArgumentCaptor<Callback> callbackArgumentCaptor = ArgumentCaptor.forClass(Callback.class);
verify(versionRecordManager, times(1)).init(eq(null), eq(path), callbackArgumentCaptor.capture());
final Callback<VersionRecord> callback = callbackArgumentCaptor.getValue();
assertNotNull(callback);
final VersionRecord versionRecord = mock(VersionRecord.class);
final ObservablePath newPath = mock(ObservablePath.class);
when(versionRecord.id()).thenReturn("id");
when(versionRecordManager.getCurrentPath()).thenReturn(newPath);
when(versionRecordManager.isLatest(versionRecord)).thenReturn(false);
callback.callback(versionRecord);
verify(versionRecordManager, times(1)).setVersion(eq("id"));
verify(document, times(1)).setVersion(eq("id"));
verify(document, times(1)).setCurrentPath(eq(newPath));
verify(document, times(1)).setReadOnly(eq(true));
verify(editor, times(1)).refreshDocument(document);
}
use of org.uberfire.java.nio.base.version.VersionRecord in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkInitialiseVersionManager.
@Test
public void checkInitialiseVersionManager() {
doNothing().when(presenter).reload();
when(versionRecordManager.isLatest(any(VersionRecord.class))).thenReturn(true);
presenter.initialiseVersionManager();
verify(versionRecordManager, times(1)).init(eq(null), eq(presenter.editorPath), versionRecordCallbackCaptor.capture());
final Callback<VersionRecord> versionRecordCallback = versionRecordCallbackCaptor.getValue();
assertNotNull(versionRecordCallback);
versionRecordCallback.callback(new PortableVersionRecord("id", "author", "email", "comment", mock(Date.class), "uri"));
verify(versionRecordManager, times(1)).setVersion(eq("id"));
verify(registeredDocumentsMenuBuilder, times(1)).setReadOnly(eq(false));
verify(presenter, times(1)).reload();
assertFalse(presenter.access.isReadOnly());
}
Aggregations