use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class JobMetaTest method testEquals_sameNameSameDirDiffRev.
@Test
public void testEquals_sameNameSameDirDiffRev() {
ObjectRevision otherRevision = mock(ObjectRevision.class);
when(otherRevision.getName()).thenReturn("otherRevision");
assertFalse(testEquals(JOB_META_NAME, directoryJob, otherRevision, null));
}
use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class AbstractMetaTest method testGetObjectNameCopyRevision.
@Test
public void testGetObjectNameCopyRevision() throws Exception {
assertNull(meta.getObjectName());
meta.setName("x");
assertEquals("x", meta.getObjectName());
assertNull(meta.getObjectCopy());
assertNull(meta.getObjectRevision());
ObjectRevision rev = mock(ObjectRevision.class);
meta.setObjectRevision(rev);
assertEquals(rev, meta.getObjectRevision());
}
use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class PurRepositoryIT method testExport.
@Test
public void testExport() throws Exception {
// $NON-NLS-1$
final String exportFileName = new File("test.export").getAbsolutePath();
RepositoryDirectoryInterface rootDir = initRepo();
String uniqueTransName = EXP_TRANS_NAME.concat(EXP_DBMETA_NAME);
TransMeta transMeta = createTransMeta(EXP_DBMETA_NAME);
// Create a database association
DatabaseMeta dbMeta = createDatabaseMeta(EXP_DBMETA_NAME);
repository.save(dbMeta, VERSION_COMMENT_V1, null);
TableInputMeta tableInputMeta = new TableInputMeta();
tableInputMeta.setDatabaseMeta(dbMeta);
transMeta.addStep(new StepMeta(EXP_TRANS_STEP_1_NAME, tableInputMeta));
RepositoryDirectoryInterface transDir = rootDir.findDirectory(DIR_TRANSFORMATIONS);
repository.save(transMeta, VERSION_COMMENT_V1, null);
// So this transformation is cleaned up afterward
deleteStack.push(transMeta);
assertNotNull(transMeta.getObjectId());
ObjectRevision version = transMeta.getObjectRevision();
assertNotNull(version);
assertTrue(hasVersionWithComment(transMeta, VERSION_COMMENT_V1));
assertTrue(repository.exists(uniqueTransName, transDir, RepositoryObjectType.TRANSFORMATION));
JobMeta jobMeta = createJobMeta(EXP_JOB_NAME);
RepositoryDirectoryInterface jobsDir = rootDir.findDirectory(DIR_JOBS);
repository.save(jobMeta, VERSION_COMMENT_V1, null);
deleteStack.push(jobMeta);
assertNotNull(jobMeta.getObjectId());
version = jobMeta.getObjectRevision();
assertNotNull(version);
assertTrue(hasVersionWithComment(jobMeta, VERSION_COMMENT_V1));
assertTrue(repository.exists(EXP_JOB_NAME, jobsDir, RepositoryObjectType.JOB));
LogListener errorLogListener = new LogListener(LogLevel.ERROR);
KettleLogStore.getAppender().addLoggingEventListener(errorLogListener);
try {
// $NON-NLS-1$
repository.getExporter().exportAllObjects(new MockProgressMonitorListener(), exportFileName, null, "all");
FileObject exportFile = KettleVFS.getFileObject(exportFileName);
assertFalse("file left open", exportFile.getContent().isOpen());
assertNotNull(exportFile);
MockRepositoryExportParser parser = new MockRepositoryExportParser();
SAXParserFactory.newInstance().newSAXParser().parse(KettleVFS.getInputStream(exportFile), parser);
if (parser.getFatalError() != null) {
throw parser.getFatalError();
}
// $NON-NLS-1$
assertNotNull("No nodes found in export", parser.getNodeNames());
// $NON-NLS-1$
assertTrue("No nodes found in export", !parser.getNodeNames().isEmpty());
// $NON-NLS-1$
assertEquals("Incorrect number of nodes", 5, parser.getNodeNames().size());
// $NON-NLS-1$ //$NON-NLS-2$
assertEquals("Incorrect number of transformations", 1, parser.getNodesWithName("transformation").size());
// $NON-NLS-1$ //$NON-NLS-2$
assertEquals("Incorrect number of jobs", 1, parser.getNodesWithName("job").size());
assertTrue("log error", errorLogListener.getEvents().isEmpty());
} finally {
KettleVFS.getFileObject(exportFileName).delete();
KettleLogStore.getAppender().removeLoggingEventListener(errorLogListener);
}
}
use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class UIEETransformationTest method testRevisions.
@Test
public void testRevisions() throws Exception {
final String revisionName = "revisionName";
final String commitMessage = "commitMessage";
ObjectRevision mockObjectRevision = mock(ObjectRevision.class);
when(mockObjectRevision.getName()).thenReturn(revisionName);
List<ObjectRevision> mockRevisions = Arrays.asList(new ObjectRevision[] { mockObjectRevision });
when(mockRevisionService.getRevisions(any(ObjectId.class))).thenReturn(mockRevisions);
uiTransformation.refreshRevisions();
verify(mockRevisionService, times(1)).getRevisions(mockObjectId);
UIRepositoryObjectRevisions revisions = uiTransformation.getRevisions();
assertEquals(1, revisions.size());
assertEquals("revisionName", revisions.get(0).getName());
verify(mockRevisionService, times(1)).getRevisions(mockObjectId);
uiTransformation.restoreRevision(revisions.get(0), commitMessage);
verify(mockRevisionService).restoreTransformation(mockObjectId, revisionName, commitMessage);
verify(mockParent, times(1)).fireCollectionChanged();
}
use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class RevisionResource method doGetVersions.
/**
* Retrieves the version history of a selected repository file
*
* <p>
* <b>Example Request:</b><br>
* GET /pur-repository-plugin/api/revision/path:to:file/revisions
* </p>
*
* @param pathId
* (colon separated path for the repository file)
*
* <pre function="syntax.xml">
* :path:to:file:id
* </pre>
* @return file revisions objects <code> purObjectRevisions </code>
*
* <pre function="syntax.xml">
* <purObjectRevisions>
* <revision>
* <versionId>1.0</versionId>
* <creationDate>2014-07-22T14:42:46.029-04:00</creationDate>
* <login>admin</login>
* <comment>JMeter test</comment>
* </revision>
* </purObjectRevisions>
* </pre>
*/
@GET
@Path("{pathId : .+}/revisions")
@StatusCodes({ @ResponseCode(code = 200, condition = "Successfully returns list of revisions"), @ResponseCode(code = 500, condition = "Something failed when attempting to retrieve revisions"), @ResponseCode(code = 404, condition = "Invalid path") })
@Produces({ APPLICATION_XML, APPLICATION_JSON })
public Response doGetVersions(@PathParam("pathId") String pathId) {
Serializable fileId = null;
List<ObjectRevision> originalRevisions = null;
RepositoryFile repositoryFile = repository.getFile(FileUtils.idToPath(pathId));
if (repositoryFile != null) {
fileId = repositoryFile.getId();
}
if (fileId != null) {
try {
originalRevisions = revisionService.getRevisions(new StringObjectId(fileId.toString()));
} catch (KettleException e) {
return Response.serverError().build();
}
List<PurObjectRevision> revisions = new ArrayList();
for (ObjectRevision revision : originalRevisions) {
revisions.add((PurObjectRevision) revision);
}
GenericEntity<List<PurObjectRevision>> genericRevisionsEntity = new GenericEntity<List<PurObjectRevision>>(revisions) {
};
return Response.ok(genericRevisionsEntity).build();
} else {
return Response.serverError().build();
}
}
Aggregations