use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class AbstractMessageParser method addVendorInformationObjects.
protected static List<VendorInformationObject> addVendorInformationObjects(final Queue<Object> objects) {
final List<VendorInformationObject> vendorInfo = new ArrayList<>();
for (Object obj = objects.peek(); obj instanceof VendorInformationObject; obj = objects.peek()) {
vendorInfo.add((VendorInformationObject) obj);
objects.remove();
}
return vendorInfo;
}
use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class APITest method testUnknownObject.
@Test
public void testUnknownObject() {
UnknownObject un = new UnknownObject(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS);
assertFalse(un.getIgnore());
assertFalse(un.getProcessingRule());
assertEquals(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS, un.getError());
assertEquals(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS.getErrorType(), un.getErrors().get(0).getErrorObject().getType());
final Object o = new CCloseBuilder().build();
UnknownObject unknown = new UnknownObject(PCEPErrors.LSP_RSVP_ERROR, o);
assertEquals(Object.class, unknown.implementedInterface());
assertEquals(o, unknown.getInvalidObject());
}
use of com.google.storage.v2.Object in project hadoop-connectors by GoogleCloudDataproc.
the class GoogleCloudStorageGrpcWriteChannel method handleResponse.
@Override
public void handleResponse(WriteObjectResponse response) {
Object resource = response.getResource();
Map<String, byte[]> metadata = resource.getMetadataMap().entrySet().stream().collect(toMap(Map.Entry::getKey, entry -> BaseEncoding.base64().decode(entry.getValue())));
byte[] md5Hash = null;
byte[] crc32c = null;
if (resource.hasChecksums()) {
md5Hash = !resource.getChecksums().getMd5Hash().isEmpty() ? resource.getChecksums().getMd5Hash().toByteArray() : null;
crc32c = resource.getChecksums().hasCrc32C() ? ByteBuffer.allocate(4).putInt(resource.getChecksums().getCrc32C()).array() : null;
}
completedItemInfo = GoogleCloudStorageItemInfo.createObject(resourceId, Timestamps.toMillis(resource.getCreateTime()), Timestamps.toMillis(resource.getUpdateTime()), resource.getSize(), resource.getContentType(), resource.getContentEncoding(), metadata, resource.getGeneration(), resource.getMetageneration(), new VerificationAttributes(md5Hash, crc32c));
}
use of com.google.storage.v2.Object in project java-storage by googleapis.
the class StorageClientTest method listObjectsTest.
@Test
public void listObjectsTest() throws Exception {
Object responsesElement = Object.newBuilder().build();
ListObjectsResponse expectedResponse = ListObjectsResponse.newBuilder().setNextPageToken("").addAllObjects(Arrays.asList(responsesElement)).build();
mockStorage.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListObjectsPagedResponse pagedListResponse = client.listObjects(parent);
List<Object> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getObjectsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockStorage.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListObjectsRequest actualRequest = ((ListObjectsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.storage.v2.Object in project java-storage by googleapis.
the class StorageClientTest method listObjectsTest2.
@Test
public void listObjectsTest2() throws Exception {
Object responsesElement = Object.newBuilder().build();
ListObjectsResponse expectedResponse = ListObjectsResponse.newBuilder().setNextPageToken("").addAllObjects(Arrays.asList(responsesElement)).build();
mockStorage.addResponse(expectedResponse);
String parent = "parent-995424086";
ListObjectsPagedResponse pagedListResponse = client.listObjects(parent);
List<Object> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getObjectsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockStorage.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListObjectsRequest actualRequest = ((ListObjectsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations