Search in sources :

Example 6 with VersionSummary

use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.

the class UnifiedRepositoryPurgeServiceTest method doPurgeUtilDateBeforeTest.

@Test
public void doPurgeUtilDateBeforeTest() throws PurgeDeletionException {
    IUnifiedRepository mockRepo = mock(IUnifiedRepository.class);
    final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap(mockRepo);
    UnifiedRepositoryPurgeService purgeService = getPurgeService(mockRepo);
    PurgeUtilitySpecification spec = new PurgeUtilitySpecification();
    spec.setBeforeDate(getDate("01/02/2006"));
    spec.setPath("/");
    purgeService.doDeleteRevisions(spec);
    verifyDateBeforeDeletion(versionListMap, mockRepo, "1", spec.getBeforeDate());
    verifyDateBeforeDeletion(versionListMap, mockRepo, "2", spec.getBeforeDate());
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Matchers.anyString(org.mockito.Matchers.anyString) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Example 7 with VersionSummary

use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.

the class UnifiedRepositoryPurgeServiceTest method deleteVersionTest.

@Test
public void deleteVersionTest() throws KettleException {
    IUnifiedRepository mockRepo = mock(IUnifiedRepository.class);
    final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap(mockRepo);
    UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService(mockRepo);
    String fileId = "1";
    String versionId = "103";
    purgeService.deleteVersion(element1, versionId);
    verify(mockRepo, times(1)).deleteFileAtVersion(fileId, versionId);
    verify(mockRepo, never()).deleteFileAtVersion(eq("2"), anyString());
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Matchers.anyString(org.mockito.Matchers.anyString) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Example 8 with VersionSummary

use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.

the class UnifiedRepositoryPurgeServiceTest method keepNumberOfVersionsTest.

@Test
public void keepNumberOfVersionsTest() throws KettleException {
    IUnifiedRepository mockRepo = mock(IUnifiedRepository.class);
    final HashMap<String, List<VersionSummary>> versionListMap = processVersionMap(mockRepo);
    UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService(mockRepo);
    String fileId = "1";
    int versionCount = 2;
    purgeService.keepNumberOfVersions(element1, versionCount);
    verifyVersionCountDeletion(versionListMap, mockRepo, fileId, versionCount);
    verify(mockRepo, never()).deleteFileAtVersion(eq("2"), anyString());
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Matchers.anyString(org.mockito.Matchers.anyString) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Example 9 with VersionSummary

use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.

the class RevisionResourceTest method getMockVersionSummaries.

/**
 * Return mock list of version summaries
 *
 * @return
 */
private List<VersionSummary> getMockVersionSummaries() {
    List<VersionSummary> versionSummaries = new ArrayList<VersionSummary>();
    VersionSummary versionSummary1 = new VersionSummary(MOCK_VERSION_ID_1, MOCK_FILE_ID, false, new Date(), MOCK_VERSION_AUTHOR_1, MOCK_VERSION_MESSAGE_1, new ArrayList<String>());
    versionSummaries.add(versionSummary1);
    return versionSummaries;
}
Also used : ArrayList(java.util.ArrayList) VersionSummary(org.pentaho.platform.api.repository2.unified.VersionSummary) Matchers.anyString(org.mockito.Matchers.anyString) Date(java.util.Date)

Example 10 with VersionSummary

use of org.pentaho.platform.api.repository2.unified.VersionSummary in project pentaho-kettle by pentaho.

the class UnifiedRepositoryPurgeService method keepNumberOfVersions.

@Override
public void keepNumberOfVersions(Serializable fileId, int versionCount) {
    List<VersionSummary> versionList = unifiedRepository.getVersionSummaries(fileId);
    int i = 0;
    int listSize = versionList.size();
    if (listSize > versionCount) {
        getLogger().info("version count: removing versions");
    }
    for (VersionSummary versionSummary : versionList) {
        if (i < listSize - versionCount) {
            Serializable versionId = versionSummary.getId();
            getLogger().debug("removing version " + versionId.toString());
            unifiedRepository.deleteFileAtVersion(fileId, versionId);
            i++;
        } else {
            break;
        }
    }
}
Also used : Serializable(java.io.Serializable) VersionSummary(org.pentaho.platform.api.repository2.unified.VersionSummary)

Aggregations

VersionSummary (org.pentaho.platform.api.repository2.unified.VersionSummary)32 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)18 Matchers.anyString (org.mockito.Matchers.anyString)17 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)16 List (java.util.List)12 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)9 Date (java.util.Date)7 ITenant (org.pentaho.platform.api.mt.ITenant)7 ByteArrayInputStream (java.io.ByteArrayInputStream)5 SimpleRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData)5 Serializable (java.io.Serializable)4 KettleException (org.pentaho.di.core.exception.KettleException)4 NodeRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)4 SampleRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.sample.SampleRepositoryFileData)4 Calendar (java.util.Calendar)3 Node (javax.jcr.Node)3 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)3 IdNotFoundException (org.pentaho.di.core.exception.IdNotFoundException)3 KettleFileException (org.pentaho.di.core.exception.KettleFileException)3