Skip to content

Commit

Permalink
chore: Adding java diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
lqiu96 committed Sep 23, 2022
1 parent eb082d2 commit 5ccc886
Show file tree
Hide file tree
Showing 1,911 changed files with 118,301 additions and 120,816 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package accessapproval;

// [START accessapproval_quickstart]
import com.google.cloud.accessapproval.v1.AccessApprovalAdminClient;
import com.google.cloud.accessapproval.v1.ApprovalRequest;
import java.io.IOException;

public class Quickstart {

public void quickstart() throws IOException {
// TODO(developer): Replace these variables before running the sample.
String projectId = "your-project-id";
quickstart(projectId);
}

public void quickstart(String projectId) throws IOException {
try (AccessApprovalAdminClient client = AccessApprovalAdminClient.create()) {
String parent = "projects/" + projectId;
AccessApprovalAdminClient.ListApprovalRequestsPagedResponse response =
client.listApprovalRequests(parent);
int total = 0;
for (ApprovalRequest request : response.iterateAll()) {
System.out.println(request.getName());
total++;
}
if (total == 0) {
System.out.println("No approval requests found");
}
}
}
}
// [END accessapproval_quickstart]
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package accessapproval;

import static org.junit.Assert.assertEquals;

import com.google.cloud.testing.junit4.StdOutCaptureRule;
import com.google.common.base.Strings;
import java.io.IOException;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;

public class QuickstartIT {
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");

@Rule public StdOutCaptureRule stdOutCap = new StdOutCaptureRule();

@BeforeClass
public static void beforeAll() throws Exception {
Assert.assertFalse("missing GOOGLE_CLOUD_PROJECT", Strings.isNullOrEmpty(PROJECT_ID));
}

@Test
public void testQuickstart() throws IOException {
Quickstart quickstart = new Quickstart();
quickstart.quickstart(PROJECT_ID);
assertEquals("No approval requests found\n", stdOutCap.getCapturedOutputAsUtf8String());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public void getModelTest() throws Exception {
.setEtag("etag3123477")
.putAllLabels(new HashMap<String, String>())
.setEncryptionSpec(EncryptionSpec.newBuilder().build())
.setModelSourceInfo(ModelSourceInfo.newBuilder().build())
.build();
mockModelService.addResponse(expectedResponse);

Expand Down Expand Up @@ -305,6 +306,7 @@ public void getModelTest2() throws Exception {
.setEtag("etag3123477")
.putAllLabels(new HashMap<String, String>())
.setEncryptionSpec(EncryptionSpec.newBuilder().build())
.setModelSourceInfo(ModelSourceInfo.newBuilder().build())
.build();
mockModelService.addResponse(expectedResponse);

Expand Down Expand Up @@ -545,6 +547,7 @@ public void updateModelTest() throws Exception {
.setEtag("etag3123477")
.putAllLabels(new HashMap<String, String>())
.setEncryptionSpec(EncryptionSpec.newBuilder().build())
.setModelSourceInfo(ModelSourceInfo.newBuilder().build())
.build();
mockModelService.addResponse(expectedResponse);

Expand Down Expand Up @@ -780,6 +783,7 @@ public void mergeVersionAliasesTest() throws Exception {
.setEtag("etag3123477")
.putAllLabels(new HashMap<String, String>())
.setEncryptionSpec(EncryptionSpec.newBuilder().build())
.setModelSourceInfo(ModelSourceInfo.newBuilder().build())
.build();
mockModelService.addResponse(expectedResponse);

Expand Down Expand Up @@ -847,6 +851,7 @@ public void mergeVersionAliasesTest2() throws Exception {
.setEtag("etag3123477")
.putAllLabels(new HashMap<String, String>())
.setEncryptionSpec(EncryptionSpec.newBuilder().build())
.setModelSourceInfo(ModelSourceInfo.newBuilder().build())
.build();
mockModelService.addResponse(expectedResponse);

Expand Down
Loading

0 comments on commit 5ccc886

Please sign in to comment.