DirectoryResource extends AbstractJaxRSResource { @GET @Path ( "{pathId : .+}/isVisible" ) @Consumes( { WILDCARD } ) @Produces( MediaType.TEXT_PLAIN ) @StatusCodes ( { @ResponseCode ( code = 200, condition = "Successfully returns a boolean value, either true or false" ) } ) public Response isDirVisible( @PathParam ( "pathId" ) String pathId ) { try { return Response.ok( ( String.valueOf( fileService.doGetIsVisible( pathId ) ) ) ).build(); } catch ( Exception e ) { return Response.ok( "false" ).build(); } } DirectoryResource();  DirectoryResource( HttpServletResponse httpServletResponse ); @PUT @Path( "{pathId : .+}" ) @Consumes( { WILDCARD } ) @StatusCodes( { @ResponseCode( code = 200, condition = "Successfully created folder." ), @ResponseCode( code = 403, condition = "Forbidden." ), @ResponseCode( code = 409, condition = "Path already exists." ), @ResponseCode( code = 500, condition = "Server Error." ) } ) Response createDirs( @PathParam ( "pathId" ) String pathId ); @GET @Path ( "{pathId : .+}/isVisible" ) @Consumes( { WILDCARD } ) @Produces( MediaType.TEXT_PLAIN ) @StatusCodes ( { @ResponseCode ( code = 200, condition = "Successfully returns a boolean value, either true or false" ) } ) Response isDirVisible( @PathParam ( "pathId" ) String pathId ); @GET @Path ( "{pathId : .+}/defaultLocation" ) @Produces( MediaType.TEXT_PLAIN ) @StatusCodes ( { @ResponseCode ( code = 200, condition = "Successfully returns a default open/save location" ) } ) Response getDefaultLocation( @PathParam ( "pathId" ) String pathId );  }
@Test public void testIsVisible() throws Exception { doReturn( "false" ).when( directoryResource.fileService ).doGetIsVisible( "/home/suzy" ); Response testResponse = directoryResource.isDirVisible( "/home/suzy"); assertEquals( Response.Status.OK.getStatusCode(), testResponse.getStatus() ); assertEquals( "false", testResponse.getEntity() ); verify( directoryResource.fileService, times( 1 ) ).doGetIsVisible( "/home/suzy" ); doReturn( "true" ).when( directoryResource.fileService ).doGetIsVisible( "/home/joe" ); Response response = directoryResource.isDirVisible( "/home/joe"); assertEquals( Response.Status.OK.getStatusCode(), response.getStatus() ); assertEquals( "true", response.getEntity() ); verify( directoryResource.fileService, times( 1 ) ).doGetIsVisible( "/home/joe" ); }