use of org.commonjava.indy.folo.client.IndyFoloAdminClientModule in project indy by Commonjava.
the class StoreFileAndRecalculateTrackingEntryTest method run.
@Test
public void run() throws Exception {
final String trackingId = newName();
byte[] oldData = ("This is a test: " + System.nanoTime()).getBytes();
InputStream stream = new ByteArrayInputStream(oldData);
final String path = "/path/to/foo.class";
client.module(IndyFoloContentClientModule.class).store(trackingId, hosted, STORE, path, stream);
IndyFoloAdminClientModule adminModule = client.module(IndyFoloAdminClientModule.class);
boolean success = adminModule.sealTrackingRecord(trackingId);
assertThat(success, equalTo(true));
TrackedContentDTO report = adminModule.getTrackingReport(trackingId);
assertThat(report, notNullValue());
Set<TrackedContentEntryDTO> uploads = report.getUploads();
assertThat(uploads, notNullValue());
assertThat(uploads.size(), equalTo(1));
TrackedContentEntryDTO entry = uploads.iterator().next();
System.out.println(entry);
assertThat(entry, notNullValue());
assertThat(entry.getStoreKey(), equalTo(new StoreKey(hosted, STORE)));
assertThat(entry.getPath(), equalTo(path));
assertThat(entry.getLocalUrl(), equalTo(client.content().contentUrl(hosted, STORE, path)));
assertThat(entry.getMd5(), equalTo(md5Hex(oldData)));
assertThat(entry.getOriginUrl(), nullValue());
byte[] newData = ("This is a REPLACED test: " + System.nanoTime()).getBytes();
stream = new ByteArrayInputStream(newData);
client.content().store(hosted, STORE, path, stream);
report = adminModule.recalculateTrackingRecord(trackingId);
assertThat(report, notNullValue());
uploads = report.getUploads();
assertThat(uploads, notNullValue());
assertThat(uploads.size(), equalTo(1));
entry = uploads.iterator().next();
System.out.println(entry);
assertThat(entry, notNullValue());
assertThat(entry.getStoreKey(), equalTo(new StoreKey(hosted, STORE)));
assertThat(entry.getPath(), equalTo(path));
assertThat(entry.getLocalUrl(), equalTo(client.content().contentUrl(hosted, STORE, path)));
assertThat(entry.getMd5(), equalTo(md5Hex(newData)));
assertThat(entry.getOriginUrl(), nullValue());
}
Aggregations