Я знаю, как настроить ADC с помощью файла учетных данных безопасности json. Насколько я понимаю, если переменная среды "GOOGLE_APPLICATION_CREDENTIALS" отсутствует в системе, выдается следующая ошибка:
Код: Выделить всё
java.io.IOException: Your default credentials were not found. To set up Application Default Credentials for your environment, see https://cloud.google.com/docs/authentication/external/set-up-adc.
Код: Выделить всё
@Before
public void setUp() throws Exception {
// Mocking the behavior of GoogleCredentials.getApplicationDefault()
// For example, if you want to return the mock credentials when getApplicationDefault() is called
when(GoogleCredentials.getApplicationDefault()).thenReturn(googleCredentialsMock);
configuration = new PropertiesConfiguration(VertexAIPredictorProvider.class.getResource("/test.properties"));
retryLogic = new RetryLogic();
vertexAIPredictorProvider = new VertexAIPredictorProvider(configuration, retryLogic);
}
@Test
public void testGetVertexAIPredictor() throws IOException {
// this class throws the above specified error
PredictorV2 predictorV2 = vertexAIPredictorProvider.getPredictor("vertexai");
assertNotNull(predictorV2);
}
Подробнее здесь: https://stackoverflow.com/questions/781 ... m-v1-using