Search in sources :

Example 11 with StoreKey

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

the class AffectedStoreRecordTest method roundTripRecordWithOneDownloadAndOneUploadToJson.

@Test
public void roundTripRecordWithOneDownloadAndOneUploadToJson() throws Exception {
    final StoreType type = StoreType.group;
    final String name = "test-group";
    final AffectedStoreRecord record = new AffectedStoreRecord(new StoreKey(type, name));
    record.add("/path/one", StoreEffect.DOWNLOAD);
    record.add("/path/two", StoreEffect.UPLOAD);
    final String json = mapper.writeValueAsString(record);
    System.out.println(json);
    final AffectedStoreRecord result = mapper.readValue(json, AffectedStoreRecord.class);
    assertThat(result, notNullValue());
    assertThat(result.getKey(), equalTo(record.getKey()));
    assertThat(result.getDownloadedPaths(), equalTo(record.getDownloadedPaths()));
    assertThat(result.getUploadedPaths(), equalTo(record.getUploadedPaths()));
}
Also used : StoreType(org.commonjava.indy.model.core.StoreType) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 12 with StoreKey

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

the class AffectedStoreRecordTest method uniqueUploadPaths.

@Test
public void uniqueUploadPaths() throws Exception {
    final StoreType type = StoreType.group;
    final String name = "test-group";
    final AffectedStoreRecord record = new AffectedStoreRecord(new StoreKey(type, name));
    record.add("/path/one", StoreEffect.UPLOAD);
    record.add("/path/one", StoreEffect.UPLOAD);
    assertThat(record.getUploadedPaths().size(), equalTo(1));
}
Also used : StoreType(org.commonjava.indy.model.core.StoreType) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 13 with StoreKey

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

the class AffectedStoreRecordTest method recordDownloadsSorted.

@Test
public void recordDownloadsSorted() throws Exception {
    final StoreType type = StoreType.group;
    final String name = "test-group";
    final AffectedStoreRecord record = new AffectedStoreRecord(new StoreKey(type, name));
    record.add("/path/two", StoreEffect.DOWNLOAD);
    record.add("/path/one", StoreEffect.DOWNLOAD);
    assertThat(record.getDownloadedPaths().iterator().next(), equalTo("/path/one"));
}
Also used : StoreType(org.commonjava.indy.model.core.StoreType) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 14 with StoreKey

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

the class AffectedStoreRecordTest method roundTripEmptyRecordToJson.

@Test
public void roundTripEmptyRecordToJson() throws Exception {
    final StoreType type = StoreType.group;
    final String name = "test-group";
    final AffectedStoreRecord record = new AffectedStoreRecord(new StoreKey(type, name));
    final String json = mapper.writeValueAsString(record);
    System.out.println(json);
    final AffectedStoreRecord result = mapper.readValue(json, AffectedStoreRecord.class);
    assertThat(result, notNullValue());
    assertThat(result.getKey(), equalTo(record.getKey()));
    assertThat(result.getDownloadedPaths(), nullValue());
    assertThat(result.getUploadedPaths(), nullValue());
}
Also used : StoreType(org.commonjava.indy.model.core.StoreType) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 15 with StoreKey

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

the class AffectedStoreRecordTest method roundTripRecordWithTwoDownloadsToJson.

@Test
public void roundTripRecordWithTwoDownloadsToJson() throws Exception {
    final StoreType type = StoreType.group;
    final String name = "test-group";
    final AffectedStoreRecord record = new AffectedStoreRecord(new StoreKey(type, name));
    record.add("/path/one", StoreEffect.DOWNLOAD);
    record.add("/path/two", StoreEffect.DOWNLOAD);
    final String json = mapper.writeValueAsString(record);
    System.out.println(json);
    final AffectedStoreRecord result = mapper.readValue(json, AffectedStoreRecord.class);
    assertThat(result, notNullValue());
    assertThat(result.getKey(), equalTo(record.getKey()));
    assertThat(result.getDownloadedPaths(), equalTo(record.getDownloadedPaths()));
    assertThat(result.getUploadedPaths(), nullValue());
}
Also used : StoreType(org.commonjava.indy.model.core.StoreType) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Aggregations

StoreKey (org.commonjava.indy.model.core.StoreKey)186 Test (org.junit.Test)92 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)40 StoreType (org.commonjava.indy.model.core.StoreType)39 InputStream (java.io.InputStream)33 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)32 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)31 IndyDataException (org.commonjava.indy.data.IndyDataException)30 Group (org.commonjava.indy.model.core.Group)29 Transfer (org.commonjava.maven.galley.model.Transfer)27 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)24 Response (javax.ws.rs.core.Response)23 IOException (java.io.IOException)22 Logger (org.slf4j.Logger)21 ApiOperation (io.swagger.annotations.ApiOperation)20 ResponseUtils.formatResponse (org.commonjava.indy.bind.jaxrs.util.ResponseUtils.formatResponse)20 ArrayList (java.util.ArrayList)19 Path (javax.ws.rs.Path)19 ApiResponse (io.swagger.annotations.ApiResponse)18 IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)18