vendredi 23 octobre 2020

Java REST API GET test

im wondering how to test GET given below. I don't have much experience with testing so would be glad if some 1 could show me proper approach or comment what should i do better.

@Path("/some")
public class SomeApi {

    @Inject
    SomeLogic someLogic;

    @GET
    @Produces({"application/json;charset=utf-8","application/json"})
    @RolesAllowed("ek_external")
    public Response getSome(@QueryParam("id") Long id, @QueryParam("name") String name, @Min(0) @DefaultValue("0") @QueryParam("offset") Integer offset, @Min(1) @Max(50) @DefaultValue("20") @QueryParam("limit") Integer limit, @Context SecurityContext securityContext) {
        return someLogic.getSome(id, name, offset, limit, securityContext);
    }
}

This is my GET. Im not sure how to handle all these QueryParams and annotated args.

Im trying something like this

@QuarkusTest
public class SomeApiTest {

    @Test
    public void testGetSome() {
        given()
                .when().get("/some")
                .then()
                .statusCode(200)
                .body()
    }
}

i ll be glad for showing me which way to go :)

Aucun commentaire:

Enregistrer un commentaire