/** * * * <pre> * The occurrences that were created. * </pre> * * <code>repeated .grafeas.v1beta1.Occurrence occurrences = 1;</code> */ public Builder setOccurrences( int index, io.grafeas.v1beta1.Occurrence.Builder builderForValue) { if (occurrencesBuilder_ == null) { ensureOccurrencesIsMutable(); occurrences_.set(index, builderForValue.build()); onChanged(); } else { occurrencesBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * The occurrences attached to the specified note. * </pre> * * <code>repeated .grafeas.v1beta1.Occurrence occurrences = 1;</code> */ public Builder addOccurrences(io.grafeas.v1beta1.Occurrence.Builder builderForValue) { if (occurrencesBuilder_ == null) { ensureOccurrencesIsMutable(); occurrences_.add(builderForValue.build()); onChanged(); } else { occurrencesBuilder_.addMessage(builderForValue.build()); } return this; } /**
/** * * * <pre> * The occurrences to create. * </pre> * * <code>repeated .grafeas.v1beta1.Occurrence occurrences = 2;</code> */ public Builder addOccurrences(io.grafeas.v1beta1.Occurrence.Builder builderForValue) { if (occurrencesBuilder_ == null) { ensureOccurrencesIsMutable(); occurrences_.add(builderForValue.build()); onChanged(); } else { occurrencesBuilder_.addMessage(builderForValue.build()); } return this; } /**
@Test @SuppressWarnings("all") public void listNoteOccurrencesTest() { String nextPageToken = ""; Occurrence occurrencesElement = Occurrence.newBuilder().build(); List<Occurrence> occurrences = Arrays.asList(occurrencesElement); ListNoteOccurrencesResponse expectedResponse = ListNoteOccurrencesResponse.newBuilder() .setNextPageToken(nextPageToken) .addAllOccurrences(occurrences) .build(); mockGrafeasV1Beta1.addResponse(expectedResponse); NoteName name = NoteName.of("[PROJECT]", "[NOTE]"); String filter = "filter-1274492040"; ListNoteOccurrencesPagedResponse pagedListResponse = client.listNoteOccurrences(name, filter); List<Occurrence> resources = Lists.newArrayList(pagedListResponse.iterateAll()); Assert.assertEquals(1, resources.size()); Assert.assertEquals(expectedResponse.getOccurrencesList().get(0), resources.get(0)); List<GeneratedMessageV3> actualRequests = mockGrafeasV1Beta1.getRequests(); Assert.assertEquals(1, actualRequests.size()); ListNoteOccurrencesRequest actualRequest = (ListNoteOccurrencesRequest) actualRequests.get(0); Assert.assertEquals(name, NoteName.parse(actualRequest.getName())); Assert.assertEquals(filter, actualRequest.getFilter()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void createOccurrenceTest() { String name = "name3373707"; String noteName = "noteName1780787896"; String remediation = "remediation779381797"; Occurrence expectedResponse = Occurrence.newBuilder() .setName(name) .setNoteName(noteName) .setRemediation(remediation) .build(); mockGrafeasV1Beta1.addResponse(expectedResponse); ProjectName parent = ProjectName.of("[PROJECT]"); Occurrence occurrence = Occurrence.newBuilder().build(); Occurrence actualResponse = client.createOccurrence(parent, occurrence); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockGrafeasV1Beta1.getRequests(); Assert.assertEquals(1, actualRequests.size()); CreateOccurrenceRequest actualRequest = (CreateOccurrenceRequest) actualRequests.get(0); Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent())); Assert.assertEquals(occurrence, actualRequest.getOccurrence()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void updateOccurrenceTest() { String name2 = "name2-1052831874"; String noteName = "noteName1780787896"; String remediation = "remediation779381797"; Occurrence expectedResponse = Occurrence.newBuilder() .setName(name2) .setNoteName(noteName) .setRemediation(remediation) .build(); mockGrafeasV1Beta1.addResponse(expectedResponse); OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]"); Occurrence occurrence = Occurrence.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); Occurrence actualResponse = client.updateOccurrence(name, occurrence, updateMask); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockGrafeasV1Beta1.getRequests(); Assert.assertEquals(1, actualRequests.size()); UpdateOccurrenceRequest actualRequest = (UpdateOccurrenceRequest) actualRequests.get(0); Assert.assertEquals(name, OccurrenceName.parse(actualRequest.getName())); Assert.assertEquals(occurrence, actualRequest.getOccurrence()); Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@Test @SuppressWarnings("all") public void getOccurrenceTest() { String name2 = "name2-1052831874"; String noteName = "noteName1780787896"; String remediation = "remediation779381797"; Occurrence expectedResponse = Occurrence.newBuilder() .setName(name2) .setNoteName(noteName) .setRemediation(remediation) .build(); mockGrafeasV1Beta1.addResponse(expectedResponse); OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]"); Occurrence actualResponse = client.getOccurrence(name); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockGrafeasV1Beta1.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetOccurrenceRequest actualRequest = (GetOccurrenceRequest) actualRequests.get(0); Assert.assertEquals(name, OccurrenceName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
/** * * * <pre> * The occurrences requested. * </pre> * * <code>repeated .grafeas.v1beta1.Occurrence occurrences = 1;</code> */ public Builder setOccurrences( int index, io.grafeas.v1beta1.Occurrence.Builder builderForValue) { if (occurrencesBuilder_ == null) { ensureOccurrencesIsMutable(); occurrences_.set(index, builderForValue.build()); onChanged(); } else { occurrencesBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * The occurrences to create. * </pre> * * <code>repeated .grafeas.v1beta1.Occurrence occurrences = 2;</code> */ public Builder setOccurrences( int index, io.grafeas.v1beta1.Occurrence.Builder builderForValue) { if (occurrencesBuilder_ == null) { ensureOccurrencesIsMutable(); occurrences_.set(index, builderForValue.build()); onChanged(); } else { occurrencesBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * The occurrences to create. * </pre> * * <code>repeated .grafeas.v1beta1.Occurrence occurrences = 2;</code> */ public Builder addOccurrences( int index, io.grafeas.v1beta1.Occurrence.Builder builderForValue) { if (occurrencesBuilder_ == null) { ensureOccurrencesIsMutable(); occurrences_.add(index, builderForValue.build()); onChanged(); } else { occurrencesBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * The occurrences requested. * </pre> * * <code>repeated .grafeas.v1beta1.Occurrence occurrences = 1;</code> */ public Builder addOccurrences(io.grafeas.v1beta1.Occurrence.Builder builderForValue) { if (occurrencesBuilder_ == null) { ensureOccurrencesIsMutable(); occurrences_.add(builderForValue.build()); onChanged(); } else { occurrencesBuilder_.addMessage(builderForValue.build()); } return this; } /**
/** * * * <pre> * The occurrences that were created. * </pre> * * <code>repeated .grafeas.v1beta1.Occurrence occurrences = 1;</code> */ public Builder addOccurrences(io.grafeas.v1beta1.Occurrence.Builder builderForValue) { if (occurrencesBuilder_ == null) { ensureOccurrencesIsMutable(); occurrences_.add(builderForValue.build()); onChanged(); } else { occurrencesBuilder_.addMessage(builderForValue.build()); } return this; } /**
/** * * * <pre> * The occurrences attached to the specified note. * </pre> * * <code>repeated .grafeas.v1beta1.Occurrence occurrences = 1;</code> */ public Builder addOccurrences( int index, io.grafeas.v1beta1.Occurrence.Builder builderForValue) { if (occurrencesBuilder_ == null) { ensureOccurrencesIsMutable(); occurrences_.add(index, builderForValue.build()); onChanged(); } else { occurrencesBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * The occurrences attached to the specified note. * </pre> * * <code>repeated .grafeas.v1beta1.Occurrence occurrences = 1;</code> */ public Builder setOccurrences( int index, io.grafeas.v1beta1.Occurrence.Builder builderForValue) { if (occurrencesBuilder_ == null) { ensureOccurrencesIsMutable(); occurrences_.set(index, builderForValue.build()); onChanged(); } else { occurrencesBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * The occurrences requested. * </pre> * * <code>repeated .grafeas.v1beta1.Occurrence occurrences = 1;</code> */ public Builder addOccurrences( int index, io.grafeas.v1beta1.Occurrence.Builder builderForValue) { if (occurrencesBuilder_ == null) { ensureOccurrencesIsMutable(); occurrences_.add(index, builderForValue.build()); onChanged(); } else { occurrencesBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * The occurrences that were created. * </pre> * * <code>repeated .grafeas.v1beta1.Occurrence occurrences = 1;</code> */ public Builder addOccurrences( int index, io.grafeas.v1beta1.Occurrence.Builder builderForValue) { if (occurrencesBuilder_ == null) { ensureOccurrencesIsMutable(); occurrences_.add(index, builderForValue.build()); onChanged(); } else { occurrencesBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * * * <pre> * The occurrence to create. * </pre> * * <code>.grafeas.v1beta1.Occurrence occurrence = 2;</code> */ public Builder setOccurrence(io.grafeas.v1beta1.Occurrence.Builder builderForValue) { if (occurrenceBuilder_ == null) { occurrence_ = builderForValue.build(); onChanged(); } else { occurrenceBuilder_.setMessage(builderForValue.build()); } return this; } /**
/** * * * <pre> * The updated occurrence. * </pre> * * <code>.grafeas.v1beta1.Occurrence occurrence = 2;</code> */ public Builder setOccurrence(io.grafeas.v1beta1.Occurrence.Builder builderForValue) { if (occurrenceBuilder_ == null) { occurrence_ = builderForValue.build(); onChanged(); } else { occurrenceBuilder_.setMessage(builderForValue.build()); } return this; } /**
@Test @SuppressWarnings("all") public void updateOccurrenceExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockGrafeasV1Beta1.addException(exception); try { OccurrenceName name = OccurrenceName.of("[PROJECT]", "[OCCURRENCE]"); Occurrence occurrence = Occurrence.newBuilder().build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateOccurrence(name, occurrence, updateMask); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }
@Test @SuppressWarnings("all") public void createOccurrenceExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockGrafeasV1Beta1.addException(exception); try { ProjectName parent = ProjectName.of("[PROJECT]"); Occurrence occurrence = Occurrence.newBuilder().build(); client.createOccurrence(parent, occurrence); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception } }