use of com.google.api.client.json.jackson.JacksonFactory in project google-cloud-eclipse by GoogleCloudPlatform.
the class ProjectRepositoryTest method testHasAppengineApplication_GoogleJsonResponseException.
@Test(expected = ProjectRepositoryException.class)
public void testHasAppengineApplication_GoogleJsonResponseException() throws IOException, ProjectRepositoryException {
Apps.Get get = initializeGetRequest();
GoogleJsonResponseException exception = GoogleJsonResponseExceptionFactoryTesting.newMock(new JacksonFactory(), 500, "Server Error");
when(get.execute()).thenThrow(exception);
repository.getAppEngineApplication(mock(Credential.class), "projectId");
}
use of com.google.api.client.json.jackson.JacksonFactory in project appengine-java-standard by GoogleCloudPlatform.
the class CloudDatastoreV1ClientImpl method getCredential.
private static Credential getCredential() throws GeneralSecurityException, IOException {
if (DatastoreServiceGlobalConfig.getConfig().emulatorHost() != null) {
logger.log(Level.INFO, "Emulator host was provided. Not using credentials.");
return null;
}
String serviceAccount = DatastoreServiceGlobalConfig.getConfig().serviceAccount();
if (serviceAccount != null) {
String privateKeyFile = DatastoreServiceGlobalConfig.getConfig().privateKeyFile();
if (privateKeyFile != null) {
logger.log(Level.INFO, "Service account and private key file were provided. " + "Using service account credential.");
return getServiceAccountCredentialBuilder(serviceAccount).setServiceAccountPrivateKeyFromP12File(new File(privateKeyFile)).build();
}
PrivateKey privateKey = DatastoreServiceGlobalConfig.getConfig().privateKey();
if (privateKey != null) {
logger.log(Level.INFO, "Service account and private key were provided. " + "Using service account credential.");
return getServiceAccountCredentialBuilder(serviceAccount).setServiceAccountPrivateKey(privateKey).build();
}
throw new IllegalStateException("Service account was provided without private key or private key file.");
}
if (DatastoreServiceGlobalConfig.getConfig().useComputeEngineCredential()) {
// See b/35156374.
return new ComputeCredential(GoogleNetHttpTransport.newTrustedTransport(), new JacksonFactory());
}
return GoogleCredential.getApplicationDefault().createScoped(DatastoreOptions.SCOPES);
}
Aggregations