Search in sources :

Example 1 with BatchDeleteRequest

use of org.commonjava.indy.model.core.BatchDeleteRequest in project indy by Commonjava.

the class BatchDeleteFromRepositoryTest method removeFilesFromRepository.

@Test
public void removeFilesFromRepository() throws Exception {
    for (String path : paths) {
        boolean exists = client.content().exists(hosted.getKey(), path);
        assertThat("The file does not exists.", exists, equalTo(true));
    }
    BatchDeleteRequest request = new BatchDeleteRequest();
    request.setStoreKey(hosted.getKey());
    request.setPaths(paths);
    client.maint().deleteFilesFromStore(request);
    for (String path : paths) {
        boolean exists = client.content().exists(hosted.getKey(), path);
        assertThat("The file is not removed.", exists, equalTo(false));
    }
}
Also used : BatchDeleteRequest(org.commonjava.indy.model.core.BatchDeleteRequest) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Example 2 with BatchDeleteRequest

use of org.commonjava.indy.model.core.BatchDeleteRequest in project indy by Commonjava.

the class RemoveFilesInTrackingReportTest method run.

@Test
public void run() throws Exception {
    final String trackingId = newName();
    final InputStream stream = new ByteArrayInputStream(("This is a test: " + System.nanoTime()).getBytes());
    final String a = "/path/to/1/foo-1.jar";
    final String b = "/path/to/2/foo-2.jar";
    final String c = "/path/to/3/foo-3.jar";
    for (String path : Arrays.asList(a, b)) {
        client.module(IndyFoloContentClientModule.class).store(trackingId, hosted, STORE, path, stream);
    }
    StoreKey key = new StoreKey(PKG_TYPE_MAVEN, hosted, STORE);
    client.content().store(key, c, stream);
    IndyFoloAdminClientModule adminModule = client.module(IndyFoloAdminClientModule.class);
    boolean success = adminModule.sealTrackingRecord(trackingId);
    assertThat(success, equalTo(true));
    boolean exists;
    for (String path : Arrays.asList(a, b)) {
        exists = client.content().exists(key, path);
        assertThat("The file does not exists.", exists, equalTo(true));
    }
    exists = client.content().exists(key, c);
    assertThat("The file does not exists.", exists, equalTo(true));
    BatchDeleteRequest request = new BatchDeleteRequest();
    request.setStoreKey(key);
    request.setTrackingID(trackingId);
    adminModule.deleteFilesFromStoreByTrackingID(request);
    for (String path : Arrays.asList(a, b)) {
        exists = client.content().exists(key, path);
        assertThat("The file is not removed.", exists, equalTo(false));
    }
    exists = client.content().exists(key, c);
    assertThat("The file does not exists.", exists, equalTo(true));
}
Also used : IndyFoloAdminClientModule(org.commonjava.indy.folo.client.IndyFoloAdminClientModule) ByteArrayInputStream(java.io.ByteArrayInputStream) BatchDeleteRequest(org.commonjava.indy.model.core.BatchDeleteRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IndyFoloContentClientModule(org.commonjava.indy.folo.client.IndyFoloContentClientModule) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test) AbstractTrackingReportTest(org.commonjava.indy.folo.ftest.report.AbstractTrackingReportTest)

Aggregations

BatchDeleteRequest (org.commonjava.indy.model.core.BatchDeleteRequest)2 Test (org.junit.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 IndyFoloAdminClientModule (org.commonjava.indy.folo.client.IndyFoloAdminClientModule)1 IndyFoloContentClientModule (org.commonjava.indy.folo.client.IndyFoloContentClientModule)1 AbstractTrackingReportTest (org.commonjava.indy.folo.ftest.report.AbstractTrackingReportTest)1 AbstractContentManagementTest (org.commonjava.indy.ftest.core.AbstractContentManagementTest)1 StoreKey (org.commonjava.indy.model.core.StoreKey)1