AttributesResource { @GET @Path("path-data") @ApiOperation(value = "Get path data instance attributes list for given workspace", response = InstanceAttributeDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of InstanceAttributeDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) public Response getPathDataAttributes( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId) throws EntityNotFoundException, UserNotActiveException, WorkspaceNotEnabledException { List<InstanceAttribute> attributes = productManager.getPathDataInstanceAttributesInWorkspace(workspaceId); return filterAttributes(attributes); } AttributesResource(); @PostConstruct void init(); @GET @Path("part-iterations") @ApiOperation(value = "Get parts instance attributes list for given workspace", response = InstanceAttributeDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of InstanceAttributeDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) Response getPartIterationsAttributes(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId); @GET @Path("path-data") @ApiOperation(value = "Get path data instance attributes list for given workspace", response = InstanceAttributeDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of InstanceAttributeDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) Response getPathDataAttributes(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId);  }
@Test public void getPathDataAttributesTest() throws ApplicationException{ String workspaceId = "wks"; List<InstanceAttribute> list = new ArrayList<>(); InstanceAttribute attribute = new InstanceTextAttribute("name","value",false); list.add(attribute); list.add(null); Mockito.when(productManager.getPathDataInstanceAttributesInWorkspace(workspaceId)) .thenReturn(list); Response res = attributesResource.getPathDataAttributes(workspaceId); Object entity = res.getEntity(); Assert.assertTrue(entity.getClass().isAssignableFrom(ArrayList.class)); ArrayList result = (ArrayList) entity; Assert.assertEquals(1, result.size()); Object o = result.get(0); Assert.assertTrue(o.getClass().isAssignableFrom(InstanceAttributeDTO.class)); InstanceAttributeDTO attr = (InstanceAttributeDTO) o; Assert.assertEquals(attribute.getName(), attr.getName()); Assert.assertEquals(null, attr.getValue()); Assert.assertEquals(false, attr.isLocked()); Assert.assertEquals(false, attr.isMandatory()); Assert.assertEquals(InstanceAttributeType.TEXT, attr.getType()); }