mardi 3 janvier 2017

RestEasy client can't use @PathParam argument

My test fails when trying to check my @GET method.

The method:

@GET
@Path("{eventId}")
public Response getEvent(@PathParam("eventId") String eventId){
    return Response.ok(this.event.getEventFromId(eventId)).build();
}

The test:

@Test
@InSequence(11)
@Header(name = "Authorization", value = "Basic cGFibG86cGFibG9wYWJsbw==")
@RunAsClient
public void testGetEventById(@ArquillianResteasyResource(BASE_PATH + "{eventId}") ResteasyWebTarget webTarget) {
    final Response response = webTarget.queryParam("eventId", "1").request().get();

    assertThat(response, hasOkStatus());

    final Event Event = EventType.readEntity(response);

    Assert.assertNotNull(Event);
}

If I put the method this way, the test works.

@GET
@Path("eventId")
public Response getEvent(){
    return Response.ok(this.event.getEventFromId("1")).build();
}

Sorry for my bad English. Thks

Aucun commentaire:

Enregistrer un commentaire