EffectivityResource { @GET @Path("/{effectivityId}") @ApiOperation(value = "Get an effectivity from its ID", response = EffectivityDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of effectivity"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) public EffectivityDTO getEffectivity( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId, @ApiParam(required = true, value = "Effectivity id") @PathParam("effectivityId") int effectivityId) throws EntityNotFoundException, UserNotActiveException, WorkspaceNotEnabledException { Effectivity effectivity = effectivityManager.getEffectivity(workspaceId, effectivityId); EffectivityDTO effectivityDTO = mapper.map(effectivity, EffectivityDTO.class); TypeEffectivity typeEffectivity = null; if (effectivity.getClass().equals(SerialNumberBasedEffectivity.class)) { typeEffectivity = TypeEffectivity.SERIALNUMBERBASEDEFFECTIVITY; } else if (effectivity.getClass().equals(DateBasedEffectivity.class)) { typeEffectivity = TypeEffectivity.DATEBASEDEFFECTIVITY; } else if (effectivity.getClass().equals(LotBasedEffectivity.class)) { typeEffectivity = TypeEffectivity.LOTBASEDEFFECTIVITY; } effectivityDTO.setTypeEffectivity(typeEffectivity); ConfigurationItem configurationItem = effectivity.getConfigurationItem(); effectivityDTO.setConfigurationItemKey(configurationItem != null ? configurationItem.getKey() : null); return effectivityDTO; } EffectivityResource(); @PostConstruct void init(); @GET @Path("/{effectivityId}") @ApiOperation(value = "Get an effectivity from its ID", response = EffectivityDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of effectivity"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) EffectivityDTO getEffectivity(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Effectivity id") @PathParam("effectivityId") int effectivityId); @PUT @ApiOperation(value = "Update effectivity", response = EffectivityDTO.class) @Path("/{effectivityId}") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of updated effectivity"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) Response updateEffectivity(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Effectivity id") @PathParam("effectivityId") int effectivityId,
            @ApiParam(required = true, value = "Effectivity values to update") EffectivityDTO effectivityDTO);  }
@Test public void getEffectivityTest() throws ApplicationException { int effectivityId = 42; String workspaceId = "wks"; Mockito.when(effectivityManager.getEffectivity(workspaceId, effectivityId)) .thenReturn(new SerialNumberBasedEffectivity()); EffectivityDTO effectivityDTO = effectivityResource.getEffectivity("wks", effectivityId); Assert.assertNotNull(effectivityDTO); Assert.assertEquals(TypeEffectivity.SERIALNUMBERBASEDEFFECTIVITY, effectivityDTO.getTypeEffectivity()); Mockito.when(effectivityManager.getEffectivity(workspaceId, effectivityId)) .thenReturn(new DateBasedEffectivity()); effectivityDTO = effectivityResource.getEffectivity("wks", effectivityId); Assert.assertNotNull(effectivityDTO); Assert.assertEquals(TypeEffectivity.DATEBASEDEFFECTIVITY, effectivityDTO.getTypeEffectivity()); Mockito.when(effectivityManager.getEffectivity(workspaceId, effectivityId)) .thenReturn(new LotBasedEffectivity()); effectivityDTO = effectivityResource.getEffectivity("wks", effectivityId); Assert.assertNotNull(effectivityDTO); Assert.assertEquals(TypeEffectivity.LOTBASEDEFFECTIVITY, effectivityDTO.getTypeEffectivity()); }