|
49 | 49 | import com.google.irm.service.v1alpha2.api.DeleteIncidentRoleAssignmentRequest;
|
50 | 50 | import com.google.irm.service.v1alpha2.api.DeleteSubscriptionRequest;
|
51 | 51 | import com.google.irm.service.v1alpha2.api.DeleteTagRequest;
|
| 52 | +import com.google.irm.service.v1alpha2.api.EscalateIncidentRequest; |
| 53 | +import com.google.irm.service.v1alpha2.api.EscalateIncidentResponse; |
52 | 54 | import com.google.irm.service.v1alpha2.api.ForceIncidentRoleHandoverRequest;
|
53 | 55 | import com.google.irm.service.v1alpha2.api.GetIncidentRequest;
|
54 | 56 | import com.google.irm.service.v1alpha2.api.GetSignalRequest;
|
|
66 | 68 | import com.google.irm.service.v1alpha2.api.ListSubscriptionsResponse;
|
67 | 69 | import com.google.irm.service.v1alpha2.api.ListTagsRequest;
|
68 | 70 | import com.google.irm.service.v1alpha2.api.ListTagsResponse;
|
| 71 | +import com.google.irm.service.v1alpha2.api.LookupSignalRequest; |
69 | 72 | import com.google.irm.service.v1alpha2.api.ProjectName;
|
70 | 73 | import com.google.irm.service.v1alpha2.api.RequestIncidentRoleHandoverRequest;
|
71 | 74 | import com.google.irm.service.v1alpha2.api.SearchIncidentsRequest;
|
|
74 | 77 | import com.google.irm.service.v1alpha2.api.SearchSignalsResponse;
|
75 | 78 | import com.google.irm.service.v1alpha2.api.SearchSimilarIncidentsRequest;
|
76 | 79 | import com.google.irm.service.v1alpha2.api.SearchSimilarIncidentsResponse;
|
| 80 | +import com.google.irm.service.v1alpha2.api.SendShiftHandoffRequest; |
| 81 | +import com.google.irm.service.v1alpha2.api.SendShiftHandoffResponse; |
77 | 82 | import com.google.irm.service.v1alpha2.api.Signal;
|
78 | 83 | import com.google.irm.service.v1alpha2.api.SignalName;
|
79 | 84 | import com.google.irm.service.v1alpha2.api.Subscription;
|
|
91 | 96 | import io.grpc.Status;
|
92 | 97 | import io.grpc.StatusRuntimeException;
|
93 | 98 | import java.io.IOException;
|
| 99 | +import java.util.ArrayList; |
94 | 100 | import java.util.Arrays;
|
95 | 101 | import java.util.List;
|
96 | 102 | import java.util.UUID;
|
@@ -903,6 +909,57 @@ public void searchSignalsExceptionTest() throws Exception {
|
903 | 909 | }
|
904 | 910 | }
|
905 | 911 |
|
| 912 | + @Test |
| 913 | + @SuppressWarnings("all") |
| 914 | + public void lookupSignalTest() { |
| 915 | + SignalName name = SignalName.of("[PROJECT]", "[SIGNAL]"); |
| 916 | + String etag = "etag3123477"; |
| 917 | + String incident = "incident86983890"; |
| 918 | + String title = "title110371416"; |
| 919 | + String contentType = "contentType831846208"; |
| 920 | + String content = "content951530617"; |
| 921 | + Signal expectedResponse = |
| 922 | + Signal.newBuilder() |
| 923 | + .setName(name.toString()) |
| 924 | + .setEtag(etag) |
| 925 | + .setIncident(incident) |
| 926 | + .setTitle(title) |
| 927 | + .setContentType(contentType) |
| 928 | + .setContent(content) |
| 929 | + .build(); |
| 930 | + mockIncidentService.addResponse(expectedResponse); |
| 931 | + |
| 932 | + LookupSignalRequest request = LookupSignalRequest.newBuilder().build(); |
| 933 | + |
| 934 | + Signal actualResponse = client.lookupSignal(request); |
| 935 | + Assert.assertEquals(expectedResponse, actualResponse); |
| 936 | + |
| 937 | + List<AbstractMessage> actualRequests = mockIncidentService.getRequests(); |
| 938 | + Assert.assertEquals(1, actualRequests.size()); |
| 939 | + LookupSignalRequest actualRequest = (LookupSignalRequest) actualRequests.get(0); |
| 940 | + |
| 941 | + Assert.assertTrue( |
| 942 | + channelProvider.isHeaderSent( |
| 943 | + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), |
| 944 | + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); |
| 945 | + } |
| 946 | + |
| 947 | + @Test |
| 948 | + @SuppressWarnings("all") |
| 949 | + public void lookupSignalExceptionTest() throws Exception { |
| 950 | + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); |
| 951 | + mockIncidentService.addException(exception); |
| 952 | + |
| 953 | + try { |
| 954 | + LookupSignalRequest request = LookupSignalRequest.newBuilder().build(); |
| 955 | + |
| 956 | + client.lookupSignal(request); |
| 957 | + Assert.fail("No exception raised"); |
| 958 | + } catch (InvalidArgumentException e) { |
| 959 | + // Expected exception |
| 960 | + } |
| 961 | + } |
| 962 | + |
906 | 963 | @Test
|
907 | 964 | @SuppressWarnings("all")
|
908 | 965 | public void getSignalTest() {
|
@@ -1010,6 +1067,48 @@ public void updateSignalExceptionTest() throws Exception {
|
1010 | 1067 | }
|
1011 | 1068 | }
|
1012 | 1069 |
|
| 1070 | + @Test |
| 1071 | + @SuppressWarnings("all") |
| 1072 | + public void escalateIncidentTest() { |
| 1073 | + EscalateIncidentResponse expectedResponse = EscalateIncidentResponse.newBuilder().build(); |
| 1074 | + mockIncidentService.addResponse(expectedResponse); |
| 1075 | + |
| 1076 | + Incident incident = Incident.newBuilder().build(); |
| 1077 | + EscalateIncidentRequest request = |
| 1078 | + EscalateIncidentRequest.newBuilder().setIncident(incident).build(); |
| 1079 | + |
| 1080 | + EscalateIncidentResponse actualResponse = client.escalateIncident(request); |
| 1081 | + Assert.assertEquals(expectedResponse, actualResponse); |
| 1082 | + |
| 1083 | + List<AbstractMessage> actualRequests = mockIncidentService.getRequests(); |
| 1084 | + Assert.assertEquals(1, actualRequests.size()); |
| 1085 | + EscalateIncidentRequest actualRequest = (EscalateIncidentRequest) actualRequests.get(0); |
| 1086 | + |
| 1087 | + Assert.assertEquals(incident, actualRequest.getIncident()); |
| 1088 | + Assert.assertTrue( |
| 1089 | + channelProvider.isHeaderSent( |
| 1090 | + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), |
| 1091 | + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); |
| 1092 | + } |
| 1093 | + |
| 1094 | + @Test |
| 1095 | + @SuppressWarnings("all") |
| 1096 | + public void escalateIncidentExceptionTest() throws Exception { |
| 1097 | + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); |
| 1098 | + mockIncidentService.addException(exception); |
| 1099 | + |
| 1100 | + try { |
| 1101 | + Incident incident = Incident.newBuilder().build(); |
| 1102 | + EscalateIncidentRequest request = |
| 1103 | + EscalateIncidentRequest.newBuilder().setIncident(incident).build(); |
| 1104 | + |
| 1105 | + client.escalateIncident(request); |
| 1106 | + Assert.fail("No exception raised"); |
| 1107 | + } catch (InvalidArgumentException e) { |
| 1108 | + // Expected exception |
| 1109 | + } |
| 1110 | + } |
| 1111 | + |
1013 | 1112 | @Test
|
1014 | 1113 | @SuppressWarnings("all")
|
1015 | 1114 | public void createArtifactTest() {
|
@@ -1160,6 +1259,68 @@ public void updateArtifactExceptionTest() throws Exception {
|
1160 | 1259 | }
|
1161 | 1260 | }
|
1162 | 1261 |
|
| 1262 | + @Test |
| 1263 | + @SuppressWarnings("all") |
| 1264 | + public void sendShiftHandoffTest() { |
| 1265 | + String contentType = "contentType831846208"; |
| 1266 | + String content = "content951530617"; |
| 1267 | + SendShiftHandoffResponse expectedResponse = |
| 1268 | + SendShiftHandoffResponse.newBuilder() |
| 1269 | + .setContentType(contentType) |
| 1270 | + .setContent(content) |
| 1271 | + .build(); |
| 1272 | + mockIncidentService.addResponse(expectedResponse); |
| 1273 | + |
| 1274 | + ProjectName parent = ProjectName.of("[PROJECT]"); |
| 1275 | + List<String> recipients = new ArrayList<>(); |
| 1276 | + String subject = "subject-1867885268"; |
| 1277 | + SendShiftHandoffRequest request = |
| 1278 | + SendShiftHandoffRequest.newBuilder() |
| 1279 | + .setParent(parent.toString()) |
| 1280 | + .addAllRecipients(recipients) |
| 1281 | + .setSubject(subject) |
| 1282 | + .build(); |
| 1283 | + |
| 1284 | + SendShiftHandoffResponse actualResponse = client.sendShiftHandoff(request); |
| 1285 | + Assert.assertEquals(expectedResponse, actualResponse); |
| 1286 | + |
| 1287 | + List<AbstractMessage> actualRequests = mockIncidentService.getRequests(); |
| 1288 | + Assert.assertEquals(1, actualRequests.size()); |
| 1289 | + SendShiftHandoffRequest actualRequest = (SendShiftHandoffRequest) actualRequests.get(0); |
| 1290 | + |
| 1291 | + Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent())); |
| 1292 | + Assert.assertEquals(recipients, actualRequest.getRecipientsList()); |
| 1293 | + Assert.assertEquals(subject, actualRequest.getSubject()); |
| 1294 | + Assert.assertTrue( |
| 1295 | + channelProvider.isHeaderSent( |
| 1296 | + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), |
| 1297 | + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); |
| 1298 | + } |
| 1299 | + |
| 1300 | + @Test |
| 1301 | + @SuppressWarnings("all") |
| 1302 | + public void sendShiftHandoffExceptionTest() throws Exception { |
| 1303 | + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); |
| 1304 | + mockIncidentService.addException(exception); |
| 1305 | + |
| 1306 | + try { |
| 1307 | + ProjectName parent = ProjectName.of("[PROJECT]"); |
| 1308 | + List<String> recipients = new ArrayList<>(); |
| 1309 | + String subject = "subject-1867885268"; |
| 1310 | + SendShiftHandoffRequest request = |
| 1311 | + SendShiftHandoffRequest.newBuilder() |
| 1312 | + .setParent(parent.toString()) |
| 1313 | + .addAllRecipients(recipients) |
| 1314 | + .setSubject(subject) |
| 1315 | + .build(); |
| 1316 | + |
| 1317 | + client.sendShiftHandoff(request); |
| 1318 | + Assert.fail("No exception raised"); |
| 1319 | + } catch (InvalidArgumentException e) { |
| 1320 | + // Expected exception |
| 1321 | + } |
| 1322 | + } |
| 1323 | + |
1163 | 1324 | @Test
|
1164 | 1325 | @SuppressWarnings("all")
|
1165 | 1326 | public void createSubscriptionTest() {
|
|
0 commit comments