package me.atam.atam4j.resources;

import me.atam.atam4j.TestRunListener;
import me.atam.atam4jdomain.TestsRunResult;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;

@Path("/tests")
public class TestStatusResource {

    private TestRunListener testRunListener;

    public TestStatusResource(TestRunListener testRunListener) {
        this.testRunListener = testRunListener;
    }

    @GET
    @Produces("application/json")
    public Response getTestStatus(){
        TestsRunResult testRunResult = testRunListener.getTestRunResult();
        if (testRunResult.getStatus().equals(TestsRunResult.Status.FAILURES)){
            return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(testRunResult).build();
        }
        return Response.status(Response.Status.OK).entity(testRunResult).build();
    }
}

@@ -161,16 +161,46 @@
 s.Path;%0A
+import javax.ws.rs.PathParam;%0A
 import j
@@ -908,11 +908,991 @@
 );%0A    %7D
+%0A%0A    @GET%0A    @Path(%22%7Bcategory%7D%22)%0A    @Produces(%22application/json%22)%0A    public Response getTestStatusForACategory(@PathParam(%22category%22) String category) %7B%0A%0A        // filter out tests that don't match category%0A        testRunListener%0A                .getTestRunResult()%0A                .getTests()%0A                .removeIf(testResult -%3E !testResult.getCategory().equalsIgnoreCase(category));%0A%0A        TestsRunResult categorisedTestsResult = new TestsRunResult(testRunListener.getTestRunResult().getTests());%0A%0A        if (categorisedTestsResult.getTests().size() %3C= 0) %7B%0A            return Response.status(Response.Status.NOT_FOUND).build();%0A        %7D else if (categorisedTestsResult.getStatus().equals(TestsRunResult.Status.FAILURES))%7B%0A            return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(categorisedTestsResult).build();%0A        %7D else %7B%0A            return Response.status(Response.Status.OK).entity(categorisedTestsResult).build();%0A        %7D%0A    %7D
 %0A%7D%0A

Add resource for category