SessionResource extends AbstractJaxRSResource { @GET @Path ( "/workspaceDirForUser/{user}" ) @Produces ( TEXT_PLAIN ) @StatusCodes ( { @ResponseCode ( code = 200, condition = "Returns the workspace file path for the specified user." ), @ResponseCode ( code = 500, condition = "File path failed to be retrieved. This could be caused by an invalid user request." ) } ) public String doGetUserDir( @PathParam ( "user" ) String user ) { return getUserHomeFolderPath( user ) + "/workspace"; } SessionResource(); @GET @Path ( "/userWorkspaceDir" ) @Produces ( TEXT_PLAIN ) @StatusCodes ( { @ResponseCode ( code = 200, condition = "Returns the requested file path" ) } ) String doGetCurrentUserDir(); @GET @Path ( "/userName" ) @Produces ( TEXT_PLAIN ) @StatusCodes ( { @ResponseCode ( code = 200, condition = "Returns the current user name" ) } ) String doGetCurrentUser(); @GET @Path ( "/workspaceDirForUser/{user}" ) @Produces ( TEXT_PLAIN ) @StatusCodes ( { @ResponseCode ( code = 200, condition = "Returns the workspace file path for the specified user." ), @ResponseCode ( code = 500, condition = "File path failed to be retrieved. This could be caused by an invalid user request." ) } ) String doGetUserDir( @PathParam ( "user" ) String user ); @GET @Path ( "/setredirect" ) @Produces ( TEXT_PLAIN ) @Facet ( name = "Unsupported" ) Response setredirect();  }
@Test public void testDoGetUserDir() { String user = "user"; String userHomeFolderPath = "path"; doReturn( userHomeFolderPath ).when( sessionResource ).getUserHomeFolderPath( user ); String testString = sessionResource.doGetUserDir( user ); assertEquals( userHomeFolderPath + "/workspace", testString ); verify( sessionResource, times( 1 ) ).getUserHomeFolderPath( user ); }