File tree Expand file tree Collapse file tree 1 file changed +15
-14
lines changed
testutil-gcloud/src/main/java/io/spine/testing/server/storage/datastore Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -128,27 +128,28 @@ public static Datastore remote(String serviceAccountPath) {
128128 */
129129 public static Datastore remote (Resource serviceAccount ) {
130130 checkNotNull (serviceAccount );
131+ Credentials credentials = credentialsFrom (serviceAccount );
132+ DatastoreOptions options = DatastoreOptions
133+ .newBuilder ()
134+ .setCredentials (credentials )
135+ .build ();
136+ Datastore datastore = options .getService ();
137+ return datastore ;
138+ }
139+
140+ private static Credentials credentialsFrom (Resource serviceAccount ) {
131141 try {
132- Credentials credentials = credentialsFrom (serviceAccount );
133- DatastoreOptions options = DatastoreOptions
134- .newBuilder ()
135- .setCredentials (credentials )
136- .build ();
137- Datastore datastore = options .getService ();
138- return datastore ;
142+ InputStream is = serviceAccount .open ();
143+ ServiceAccountCredentials credentials = fromStream (is );
144+ return credentials ;
139145 } catch (IOException e ) {
140146 throw newIllegalStateException (
141- e , "Problems parsing the credentials file `%s`." , serviceAccount
147+ e , "Unable to parse Service Account credentials from `%s` resource." ,
148+ serviceAccount
142149 );
143150 }
144151 }
145152
146- private static Credentials credentialsFrom (Resource serviceAccount ) throws IOException {
147- InputStream is = serviceAccount .open ();
148- ServiceAccountCredentials credentials = fromStream (is );
149- return credentials ;
150- }
151-
152153 /**
153154 * Returns the default project ID that is used when running on a local Datastore emulator.
154155 */
You can’t perform that action at this time.
0 commit comments