Search in sources :

Example 1 with CreateOccurrenceRequest

use of io.grafeas.v1beta1.CreateOccurrenceRequest in project java-containeranalysis by googleapis.

the class GrafeasV1Beta1ClientTest method createOccurrenceTest.

@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<AbstractMessage> 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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.containeranalysis.v1beta1.ProjectName) CreateOccurrenceRequest(io.grafeas.v1beta1.CreateOccurrenceRequest) Occurrence(io.grafeas.v1beta1.Occurrence) Test(org.junit.Test)

Aggregations

ProjectName (com.google.containeranalysis.v1beta1.ProjectName)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 CreateOccurrenceRequest (io.grafeas.v1beta1.CreateOccurrenceRequest)1 Occurrence (io.grafeas.v1beta1.Occurrence)1 Test (org.junit.Test)1