Examples of BlobMetrics


Examples of org.sonatype.nexus.blobstore.api.BlobMetrics

    final Path fakePath = root.resolve("fakePath" + FileBlobStore.BLOB_CONTENT_SUFFIX);
    when(fileOps.create(fakePath, inputStream)).thenReturn(new StreamMetrics(contentSize, fakeSHA1));

    final Blob blob = underTest.create(inputStream, headers);

    final BlobMetrics metrics = blob.getMetrics();

    assertThat(metrics.getSHA1Hash(), is(equalTo(fakeSHA1)));
    assertThat(metrics.getContentSize(), is(equalTo(contentSize)));

    assertTrue("Creation time should be very recent",
        metrics.getCreationTime().isAfter(new DateTime().minusSeconds(2)));
  }
View Full Code Here

Examples of org.sonatype.nexus.blobstore.api.BlobMetrics

public class MetadataRecordExternalizationTest
{
  @Test
  public void roundTrip() throws Exception {
    final BlobMetadata blobMetadata = new BlobMetadata(BlobState.CREATING, ImmutableMap.of("Hi", "mom"));
    blobMetadata.setMetrics(new BlobMetrics(new DateTime(), "pretend hash", 33434));

    roundTrip(blobMetadata);
  }
View Full Code Here

Examples of org.sonatype.nexus.blobstore.api.BlobMetrics

  public void roundTripWithEmptyObject() throws Exception {
    final Map<String, String> headers = new HashMap<>();
    headers.put(null, null);

    final BlobMetadata blobMetadata = new BlobMetadata(BlobState.CREATING, headers);
    blobMetadata.setMetrics(new BlobMetrics(null, null, 0));

    roundTrip(blobMetadata);
  }
View Full Code Here

Examples of org.sonatype.nexus.blobstore.api.BlobMetrics

  }

  private BlobMetadata convert(final MetadataRecord source) {
    BlobMetadata target = new BlobMetadata(source.state, Maps.newHashMap(source.headers));
    if (source.metrics) {
      target.setMetrics(new BlobMetrics(source.created, source.sha1, source.size));
    }
    return target;
  }
View Full Code Here

Examples of org.sonatype.nexus.blobstore.api.BlobMetrics

    }

    public MetadataRecord(final BlobMetadata source) {
      this.state = source.getBlobState();
      this.headers = Maps.newHashMap(source.getHeaders());
      BlobMetrics metrics = source.getMetrics();
      if (metrics != null) {
        this.metrics = true;
        this.created = metrics.getCreationTime();
        this.sha1 = metrics.getSHA1Hash();
        this.size = metrics.getContentSize();
      }
      else {
        this.metrics = false;
        this.created = null;
        this.sha1 = null;
View Full Code Here

Examples of org.sonatype.nexus.blobstore.api.BlobMetrics

      final Path path = pathFor(blobId);
      log.debug("Writing blob {} to {}", blobId, path);

      final StreamMetrics streamMetrics = fileOperations.create(path, blobData);
      final BlobMetrics metrics = new BlobMetrics(new DateTime(), streamMetrics.getSHA1(), streamMetrics.getSize());
      final FileBlob blob = new FileBlob(blobId, headers, path, metrics);

      if (listener != null) {
        listener.blobCreated(blob, "Blob: " + blobId + " written to: " + path);
      }
View Full Code Here

Examples of org.sonatype.nexus.blobstore.api.BlobMetrics

    final Blob blob = underTest.create(new ByteArrayInputStream(content), TEST_HEADERS);

    final byte[] output = extractContent(blob);
    assertThat("data must survive", content, is(equalTo(output)));

    final BlobMetrics metrics = blob.getMetrics();
    assertThat("size must be calculated correctly", metrics.getContentSize(), is(equalTo((long) TEST_DATA_LENGTH)));

    final BlobStoreMetrics storeMetrics = underTest.getMetrics();
    assertThat(storeMetrics.getBlobCount(), is(equalTo(1L)));

    // FIXME: This is no longer valid
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.