Search in sources :

Example 1 with PutResult

use of com.github.ambry.named.PutResult in project ambry by linkedin.

the class AmbryIdConverterFactoryTest method ambryIdConverterNamedBlobTest.

@Test
public void ambryIdConverterNamedBlobTest() throws Exception {
    Properties properties = new Properties();
    VerifiableProperties verifiableProperties = new VerifiableProperties(properties);
    IdSigningService idSigningService = mock(IdSigningService.class);
    NamedBlobDb namedBlobDb = mock(NamedBlobDb.class);
    AmbryIdConverterFactory ambryIdConverterFactory = new AmbryIdConverterFactory(verifiableProperties, new MetricRegistry(), idSigningService, namedBlobDb);
    IdConverter idConverter = ambryIdConverterFactory.getIdConverter();
    assertNotNull("No IdConverter returned", idConverter);
    PartitionId partitionId = new MockPartitionId(partition, MockClusterMap.DEFAULT_PARTITION_CLASS);
    BlobId blobId = new BlobId(BLOB_ID_V6, BlobIdType.NATIVE, dataCenterId, accountId, containerId, partitionId, false, BlobDataType.DATACHUNK);
    List<String> idList = new ArrayList<>();
    idList.add(blobId.getID());
    for (String id : idList) {
        reset(idSigningService);
        reset(namedBlobDb);
        when(namedBlobDb.put(any())).thenReturn(CompletableFuture.completedFuture(new PutResult(new NamedBlobRecord("", "", "", id, Utils.Infinite_Time))));
        testConversionForNamedBlob(idConverter, RestMethod.PUT, null, id, id);
        verify(idSigningService, never()).getSignedId(any(), any());
        verify(namedBlobDb).put(any());
    }
}
Also used : VerifiableProperties(com.github.ambry.config.VerifiableProperties) NamedBlobDb(com.github.ambry.named.NamedBlobDb) MockPartitionId(com.github.ambry.clustermap.MockPartitionId) MetricRegistry(com.codahale.metrics.MetricRegistry) ArrayList(java.util.ArrayList) BlobProperties(com.github.ambry.messageformat.BlobProperties) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) MockPartitionId(com.github.ambry.clustermap.MockPartitionId) PartitionId(com.github.ambry.clustermap.PartitionId) BlobId(com.github.ambry.commons.BlobId) PutResult(com.github.ambry.named.PutResult) NamedBlobRecord(com.github.ambry.named.NamedBlobRecord) Test(org.junit.Test)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)1 MockPartitionId (com.github.ambry.clustermap.MockPartitionId)1 PartitionId (com.github.ambry.clustermap.PartitionId)1 BlobId (com.github.ambry.commons.BlobId)1 VerifiableProperties (com.github.ambry.config.VerifiableProperties)1 BlobProperties (com.github.ambry.messageformat.BlobProperties)1 NamedBlobDb (com.github.ambry.named.NamedBlobDb)1 NamedBlobRecord (com.github.ambry.named.NamedBlobRecord)1 PutResult (com.github.ambry.named.PutResult)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Test (org.junit.Test)1