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()));
}
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));
}
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"));
}
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());
}
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());
}
Aggregations