Tabnine Logo
GoogleJsonError.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
com.google.api.client.googleapis.json.GoogleJsonError
constructor

Best Java code snippets using com.google.api.client.googleapis.json.GoogleJsonError.<init> (Showing top 20 results out of 315)

origin: googleapis/google-cloud-java

 throw exception;
GoogleJsonError error = new GoogleJsonError();
error.setCode(code);
error.setMessage(message);
origin: googleapis/google-cloud-java

@Test
public void testUpdateAllIterable() {
 RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
 Capture<RpcBatch.Callback<StorageObject>> callback1 = Capture.newInstance();
 Capture<RpcBatch.Callback<StorageObject>> callback2 = Capture.newInstance();
 batchMock.addPatch(
   EasyMock.eq(BLOB_INFO1.toPb()),
   EasyMock.capture(callback1),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 batchMock.addPatch(
   EasyMock.eq(BLOB_INFO2.toPb()),
   EasyMock.capture(callback2),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 EasyMock.expect(storageRpcMock.createBatch()).andReturn(batchMock);
 batchMock.submit();
 EasyMock.replay(storageRpcMock, batchMock);
 initializeService();
 List<Blob> resultBlobs = storage.update(ImmutableList.of(BLOB_INFO1, BLOB_INFO2));
 callback1.getValue().onSuccess(BLOB_INFO1.toPb());
 callback2.getValue().onFailure(new GoogleJsonError());
 assertEquals(2, resultBlobs.size());
 assertEquals(new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO1)), resultBlobs.get(0));
 assertNull(resultBlobs.get(1));
 EasyMock.verify(batchMock);
}
origin: googleapis/google-cloud-java

@Test
public void testDeleteAllArray() {
 BlobId blobId1 = BlobId.of(BUCKET_NAME1, BLOB_NAME1);
 BlobId blobId2 = BlobId.of(BUCKET_NAME1, BLOB_NAME2);
 RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
 Capture<RpcBatch.Callback<Void>> callback1 = Capture.newInstance();
 Capture<RpcBatch.Callback<Void>> callback2 = Capture.newInstance();
 batchMock.addDelete(
   EasyMock.eq(blobId1.toPb()),
   EasyMock.capture(callback1),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 batchMock.addDelete(
   EasyMock.eq(blobId2.toPb()),
   EasyMock.capture(callback2),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 EasyMock.expect(storageRpcMock.createBatch()).andReturn(batchMock);
 batchMock.submit();
 EasyMock.replay(storageRpcMock, batchMock);
 initializeService();
 List<Boolean> result = storage.delete(blobId1, blobId2);
 callback1.getValue().onSuccess(null);
 callback2.getValue().onFailure(new GoogleJsonError());
 assertEquals(2, result.size());
 assertTrue(result.get(0));
 assertFalse(result.get(1));
 EasyMock.verify(batchMock);
}
origin: googleapis/google-cloud-java

@Test
public void testDeleteAllIterable() {
 BlobId blobId1 = BlobId.of(BUCKET_NAME1, BLOB_NAME1);
 BlobId blobId2 = BlobId.of(BUCKET_NAME1, BLOB_NAME2);
 RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
 Capture<RpcBatch.Callback<Void>> callback1 = Capture.newInstance();
 Capture<RpcBatch.Callback<Void>> callback2 = Capture.newInstance();
 batchMock.addDelete(
   EasyMock.eq(blobId1.toPb()),
   EasyMock.capture(callback1),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 batchMock.addDelete(
   EasyMock.eq(blobId2.toPb()),
   EasyMock.capture(callback2),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 EasyMock.expect(storageRpcMock.createBatch()).andReturn(batchMock);
 batchMock.submit();
 EasyMock.replay(storageRpcMock, batchMock);
 initializeService();
 List<Boolean> result = storage.delete(blobId1, blobId2);
 callback1.getValue().onSuccess(null);
 callback2.getValue().onFailure(new GoogleJsonError());
 assertEquals(2, result.size());
 assertTrue(result.get(0));
 assertFalse(result.get(1));
 EasyMock.verify(batchMock);
}
origin: googleapis/google-cloud-java

GoogleJsonError error = new GoogleJsonError();
error.setCode(response.getStatusCode());
error.setMessage(response.getStatusMessage());
origin: googleapis/google-cloud-java

@Test
public void testUpdateAllArray() {
 RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
 Capture<RpcBatch.Callback<StorageObject>> callback1 = Capture.newInstance();
 Capture<RpcBatch.Callback<StorageObject>> callback2 = Capture.newInstance();
 batchMock.addPatch(
   EasyMock.eq(BLOB_INFO1.toPb()),
   EasyMock.capture(callback1),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 batchMock.addPatch(
   EasyMock.eq(BLOB_INFO2.toPb()),
   EasyMock.capture(callback2),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 EasyMock.expect(storageRpcMock.createBatch()).andReturn(batchMock);
 batchMock.submit();
 EasyMock.replay(storageRpcMock, batchMock);
 initializeService();
 List<Blob> resultBlobs = storage.update(BLOB_INFO1, BLOB_INFO2);
 callback1.getValue().onSuccess(BLOB_INFO1.toPb());
 callback2.getValue().onFailure(new GoogleJsonError());
 assertEquals(2, resultBlobs.size());
 assertEquals(new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO1)), resultBlobs.get(0));
 assertNull(resultBlobs.get(1));
 EasyMock.verify(batchMock);
}
origin: googleapis/google-cloud-java

@Test
public void testGetAllArrayIterable() {
 BlobId blobId1 = BlobId.of(BUCKET_NAME1, BLOB_NAME1);
 BlobId blobId2 = BlobId.of(BUCKET_NAME1, BLOB_NAME2);
 RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
 Capture<RpcBatch.Callback<StorageObject>> callback1 = Capture.newInstance();
 Capture<RpcBatch.Callback<StorageObject>> callback2 = Capture.newInstance();
 batchMock.addGet(
   EasyMock.eq(blobId1.toPb()),
   EasyMock.capture(callback1),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 batchMock.addGet(
   EasyMock.eq(blobId2.toPb()),
   EasyMock.capture(callback2),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 EasyMock.expect(storageRpcMock.createBatch()).andReturn(batchMock);
 batchMock.submit();
 EasyMock.replay(storageRpcMock, batchMock);
 initializeService();
 List<Blob> resultBlobs = storage.get(ImmutableList.of(blobId1, blobId2));
 callback1.getValue().onSuccess(BLOB_INFO1.toPb());
 callback2.getValue().onFailure(new GoogleJsonError());
 assertEquals(2, resultBlobs.size());
 assertEquals(new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO1)), resultBlobs.get(0));
 assertNull(resultBlobs.get(1));
 EasyMock.verify(batchMock);
}
origin: googleapis/google-cloud-java

@Test
public void testGetAllArray() {
 BlobId blobId1 = BlobId.of(BUCKET_NAME1, BLOB_NAME1);
 BlobId blobId2 = BlobId.of(BUCKET_NAME1, BLOB_NAME2);
 RpcBatch batchMock = EasyMock.createMock(RpcBatch.class);
 Capture<RpcBatch.Callback<StorageObject>> callback1 = Capture.newInstance();
 Capture<RpcBatch.Callback<StorageObject>> callback2 = Capture.newInstance();
 batchMock.addGet(
   EasyMock.eq(blobId1.toPb()),
   EasyMock.capture(callback1),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 batchMock.addGet(
   EasyMock.eq(blobId2.toPb()),
   EasyMock.capture(callback2),
   EasyMock.eq(ImmutableMap.<StorageRpc.Option, Object>of()));
 EasyMock.expect(storageRpcMock.createBatch()).andReturn(batchMock);
 batchMock.submit();
 EasyMock.replay(storageRpcMock, batchMock);
 initializeService();
 List<Blob> resultBlobs = storage.get(blobId1, blobId2);
 callback1.getValue().onSuccess(BLOB_INFO1.toPb());
 callback2.getValue().onFailure(new GoogleJsonError());
 assertEquals(2, resultBlobs.size());
 assertEquals(new Blob(storage, new BlobInfo.BuilderImpl(BLOB_INFO1)), resultBlobs.get(0));
 assertNull(resultBlobs.get(1));
 EasyMock.verify(batchMock);
}
origin: googleapis/google-cloud-java

@Test
public void testGetZoneNotFound() {
 EasyMock.reset(batchMock);
 Capture<RpcBatch.Callback<ManagedZone>> callback = Capture.newInstance();
 Capture<Map<DnsRpc.Option, Object>> capturedOptions = Capture.newInstance();
 batchMock.addGetZone(
   EasyMock.eq(ZONE_NAME), EasyMock.capture(callback), EasyMock.capture(capturedOptions));
 EasyMock.replay(batchMock);
 DnsBatchResult<Zone> batchResult = dnsBatch.getZone(ZONE_NAME);
 assertEquals(0, capturedOptions.getValue().size());
 GoogleJsonError error = new GoogleJsonError();
 error.setCode(404);
 RpcBatch.Callback<ManagedZone> capturedCallback = callback.getValue();
 capturedCallback.onFailure(error);
 assertNull(batchResult.get());
}
origin: googleapis/google-cloud-java

@Test
public void testGetChangeRequestNotFound() {
 EasyMock.reset(batchMock);
 Capture<RpcBatch.Callback<Change>> callback = Capture.newInstance();
 Capture<Map<DnsRpc.Option, Object>> capturedOptions = Capture.newInstance();
 batchMock.addGetChangeRequest(
   EasyMock.eq(ZONE_NAME),
   EasyMock.eq(CHANGE_REQUEST_COMPLETE.getGeneratedId()),
   EasyMock.capture(callback),
   EasyMock.capture(capturedOptions));
 EasyMock.replay(batchMock);
 DnsBatchResult<ChangeRequest> batchResult =
   dnsBatch.getChangeRequest(ZONE_NAME, CHANGE_REQUEST_COMPLETE.getGeneratedId());
 assertEquals(0, capturedOptions.getValue().size());
 RpcBatch.Callback<Change> capturedCallback = callback.getValue();
 GoogleJsonError error = new GoogleJsonError();
 GoogleJsonError.ErrorInfo errorInfo = new GoogleJsonError.ErrorInfo();
 errorInfo.setReason("reason");
 errorInfo.setLocation("entity.parameters.changeId");
 error.setCode(404);
 error.setErrors(ImmutableList.of(errorInfo));
 capturedCallback.onFailure(error);
 assertNull(batchResult.get());
}
origin: googleapis/google-cloud-java

GoogleJsonError error = new GoogleJsonError();
error.setCode(404);
capturedCallback.onFailure(error);
origin: googleapis/google-cloud-java

GoogleJsonError error = new GoogleJsonError();
error.setCode(404);
capturedCallback.onFailure(error);
origin: googleapis/google-cloud-java

assertEquals(exception, serviceException.getCause());
GoogleJsonError error = new GoogleJsonError();
error.setCode(CODE);
error.setMessage(MESSAGE);
origin: googleapis/google-cloud-java

assertSame(cause, exception.getCause());
GoogleJsonError error = new GoogleJsonError();
error.setCode(503);
error.setMessage("message");
origin: googleapis/google-cloud-java

assertSame(cause, exception.getCause());
GoogleJsonError error = new GoogleJsonError();
error.setCode(503);
error.setMessage("message");
origin: com.google.enterprise.cloudsearch/google-cloudsearch-connector-sdk

 private GoogleJsonError getGoogleJsonError(Exception e) {
  if (e instanceof GoogleJsonResponseException) {
   return ((GoogleJsonResponseException) e).getDetails();
  }
  boolean retryableException =
    (e instanceof SSLHandshakeException || e instanceof SocketTimeoutException);
  if (retryableException) {
   logger.log(Level.WARNING, "Retrying request failed with exception:", e);
  }
  // Using retryable 504 Gateway Timeout error code.
  int errorCode = retryableException ? 504 : 0;
  GoogleJsonError error = new GoogleJsonError();
  error.setMessage(e.getMessage());
  error.setCode(errorCode);
  return error;
 }
}
origin: GoogleCloudPlatform/bigdata-interop

/**
 * Validates itemNotFound().
 */
@Test
public void testItemNotFound() {
 // Check success cases.
 assertThat(errorExtractor.itemNotFound(notFound)).isTrue();
 GoogleJsonError gje = new GoogleJsonError();
 gje.setCode(HttpStatusCodes.STATUS_CODE_NOT_FOUND);
 assertThat(errorExtractor.itemNotFound(gje)).isTrue();
 assertThat(errorExtractor.itemNotFound(new IOException(notFound))).isTrue();
 assertThat(errorExtractor.itemNotFound(new IOException(new IOException(notFound)))).isTrue();
 // Check failure case.
 assertThat(errorExtractor.itemNotFound(statusOk)).isFalse();
 assertThat(errorExtractor.itemNotFound(new IOException())).isFalse();
 assertThat(errorExtractor.itemNotFound(new IOException(new IOException()))).isFalse();
}
origin: org.apache.beam/beam-sdks-java-io-google-cloud-platform

/** A helper that generates the error JSON payload that Google APIs produce. */
private static GoogleJsonErrorContainer errorWithReasonAndStatus(String reason, int status) {
 ErrorInfo info = new ErrorInfo();
 info.setReason(reason);
 info.setDomain("global");
 // GoogleJsonError contains one or more ErrorInfo objects; our utiities read the first one.
 GoogleJsonError error = new GoogleJsonError();
 error.setErrors(ImmutableList.of(info));
 error.setCode(status);
 error.setMessage(reason);
 // The actual JSON response is an error container.
 GoogleJsonErrorContainer container = new GoogleJsonErrorContainer();
 container.setError(error);
 return container;
}
origin: GoogleCloudPlatform/bigdata-interop

public LowLevelHttpRequest buildRequest(String method, String url) throws IOException {
 errorInfo.setFactory(jsonFactory);
 GoogleJsonError jsonError = new GoogleJsonError();
 jsonError.setCode(status);
 jsonError.setErrors(Collections.singletonList(errorInfo));
origin: GoogleCloudPlatform/bigdata-interop

 @Override
 public LowLevelHttpRequest buildRequest(String method, String url) throws IOException {
  errorInfo.setFactory(jsonFactory);
  GoogleJsonError jsonError = new GoogleJsonError();
  jsonError.setCode(status);
  jsonError.setErrors(Collections.singletonList(errorInfo));
  jsonError.setMessage(httpStatusString);
  jsonError.setFactory(jsonFactory);
  GenericJson errorResponse = new GenericJson();
  errorResponse.set("error", jsonError);
  errorResponse.setFactory(jsonFactory);
  return new MockLowLevelHttpRequest()
    .setResponse(
      new MockLowLevelHttpResponse()
        .setContent(errorResponse.toPrettyString())
        .setContentType(Json.MEDIA_TYPE)
        .setStatusCode(status));
 }
};
com.google.api.client.googleapis.jsonGoogleJsonError<init>

Popular methods of GoogleJsonError

  • getMessage
    Returns the human-readable explanation of the error or null for none.
  • getCode
    Returns the HTTP status code of this response or null for none.
  • getErrors
    Returns the list of detailed errors or null for none.
  • setCode
    Sets the HTTP status code of this response or null for none.
  • setMessage
    Sets the human-readable explanation of the error or null for none.
  • setErrors
    Sets the list of detailed errors or null for none.
  • toPrettyString
  • get
  • setFactory
  • toString

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getResourceAsStream (ClassLoader)
  • onRequestPermissionsResult (Fragment)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Menu (java.awt)
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now