PreparationController { @RequestMapping(value = "/preparations/{id}/details", method = GET) @ApiOperation(value = "Get preparation details", notes = "Return the details of the preparation with provided id.") @Timed public PreparationDTO getDetails( @ApiParam("id") @PathVariable("id") String id, @ApiParam(value = "stepId", defaultValue = "head") @RequestParam(value = "stepId", defaultValue = "head") String stepId) { return preparationService.getPreparationDetails(id, stepId); }  @RequestMapping(value = "/preparations", method = POST) @ApiOperation(value = "Create a preparation", notes = "Returns the id of the created preparation.") @Timed String create(@ApiParam("preparation") @RequestBody @Valid final Preparation preparation,
            @ApiParam(value = "The folderId path to create the entry.") @RequestParam String folderId); @RequestMapping(value = "/preparations", method = GET) @ApiOperation(value = "List all preparations id", notes = "Returns the list of preparations ids the current user is allowed to see. Creation date is always displayed in UTC time zone. See 'preparations/all' to get all details at once.") @Timed Stream<String> list(
            @ApiParam(name = "name",
                    value = "Filter preparations by name.") @RequestParam(required = false) String name,
            @ApiParam(name = "folder_path", value = "Filter preparations by folder path.") @RequestParam(
                    required = false, name = "folder_path") String folderPath,
            @ApiParam(name = "path",
                    value = "Filter preparations by full path (<folder path>/<preparation name>).") @RequestParam(
                            required = false, name = "path") String path,
            @ApiParam(value = "Sort key (by name or date).") @RequestParam(
                    defaultValue = "lastModificationDate") Sort sort,
            @ApiParam(value = "Order for sort key (desc or asc).") @RequestParam(defaultValue = "desc") Order order); @RequestMapping(value = "/preparations/details", method = GET) @ApiOperation(value = "List all preparations", notes = "Returns the list of preparations details the current user is allowed to see. Creation date is always displayed in UTC time zone. This operation return all details on the preparations.") @Timed Stream<PreparationDTO> listAll(
            @ApiParam(name = "name",
                    value = "Filter preparations by name.") @RequestParam(required = false) String name,
            @ApiParam(name = "folder_path", value = "Filter preparations by folder path.") @RequestParam(
                    required = false, name = "folder_path") String folderPath,
            @ApiParam(name = "path",
                    value = "Filter preparations by full path (<folder path>/<preparation name>).") @RequestParam(
                            required = false, name = "path") String path,
            @ApiParam(value = "Sort key (by name or date).") @RequestParam(
                    defaultValue = "lastModificationDate") Sort sort,
            @ApiParam(value = "Order for sort key (desc or asc).") @RequestParam(defaultValue = "desc") Order order); @RequestMapping(value = "/preparations/summaries", method = GET) @ApiOperation(value = "List all preparations", notes = "Returns the list of preparations summaries the current user is allowed to see. Creation date is always displayed in UTC time zone.") @Timed Stream<PreparationDTO> listSummary(
            @ApiParam(name = "name",
                    value = "Filter preparations by name.") @RequestParam(required = false) String name,
            @ApiParam(name = "folder_path", value = "Filter preparations by folder path.") @RequestParam(
                    required = false, name = "folder_path") String folderPath,
            @ApiParam(name = "path",
                    value = "Filter preparations by full path (<folder path>/<preparation name>).") @RequestParam(
                            required = false, name = "path") String path,
            @ApiParam(value = "Sort key (by name or date).") @RequestParam(
                    defaultValue = "lastModificationDate") Sort sort,
            @ApiParam(value = "Order for sort key (desc or asc).") @RequestParam(defaultValue = "desc") Order order); @RequestMapping(value = "/preparations/search", method = GET) @ApiOperation(value = "Search for preparations details", notes = "Returns the list of preparations details that match the search criteria.") @Timed Stream<PreparationDTO> searchPreparations(
            @RequestParam(required = false) @ApiParam("dataSetId") String dataSetId,
            @RequestParam(required = false) @ApiParam(
                    value = "Id of the folder where to look for preparations") String folderId,
            @RequestParam(required = false) @ApiParam(
                    value = "Path of the folder where to look for preparations") String folderPath,
            @RequestParam(required = false) @ApiParam("name") String name,
            @RequestParam(defaultValue = "true") @ApiParam("exactMatch") boolean exactMatch,
            @RequestParam(defaultValue = "lastModificationDate") @ApiParam(
                    value = "Sort key (by name or date).") Sort sort,
            @RequestParam(defaultValue = "desc") @ApiParam(value = "Order for sort key (desc or asc).") Order order); @RequestMapping(value = "/preparations/{id}/copy", method = POST, produces = TEXT_PLAIN_VALUE) @ApiOperation(value = "Copy a preparation", produces = TEXT_PLAIN_VALUE, notes = "Copy the preparation to the new name / folder and returns the new id.") @Timed String copy(
            @PathVariable(value = "id") @ApiParam(name = "id",
                    value = "Id of the preparation to copy") String preparationId,
            @ApiParam(value = "The name of the copied preparation.") @RequestParam(required = false) String name,
            @ApiParam(value = "The folder path to create the copy.") @RequestParam() String destination); @RequestMapping(value = "/preparations/{id}/move", method = PUT) @ApiOperation(value = "Move a preparation", notes = "Move a preparation to an other folder.") @Timed void move(
            @PathVariable(value = "id") @ApiParam(name = "id",
                    value = "Id of the preparation to move") String preparationId,
            @ApiParam(value = "The original folder path of the preparation.") @RequestParam String folder,
            @ApiParam(value = "The new folder path of the preparation.") @RequestParam String destination,
            @ApiParam(value = "The new name of the moved dataset.") @RequestParam(defaultValue = "") String newName); @RequestMapping(value = "/preparations/{id}", method = RequestMethod.DELETE) @ApiOperation(value = "Delete a preparation by id", notes = "Delete a preparation content based on provided id. Id should be a UUID returned by the list operation. Not valid or non existing preparation id returns empty content.") @Timed void delete(
            @PathVariable(value = "id") @ApiParam(name = "id", value = "Id of the preparation to delete") String id); @RequestMapping(value = "/preparations/{id}", method = PUT) @ApiOperation(value = "Create a preparation", notes = "Returns the id of the updated preparation.") @Timed String update(@ApiParam("id") @PathVariable("id") String id,
            @RequestBody @ApiParam("preparation") final PreparationDTO preparation); @RequestMapping(value = "/preparations/steps/{stepId}/metadata", method = PUT, produces = TEXT_PLAIN_VALUE, consumes = APPLICATION_JSON_VALUE) @ApiOperation(value = "Update a preparation steps", notes = "Returns the id of the updated step.") @Timed String updateStepMetadata(@ApiParam("stepId") @PathVariable("stepId") String stepId,
            @RequestBody @ApiParam("rowMetadata") final RowMetadata rowMetadata); @RequestMapping(value = "/preparations/steps/{stepId}/metadata", method = DELETE) @ApiOperation(value = "Deletes the metadata associated with step") @Timed void invalidateStepMetadata(@ApiParam("stepId") @PathVariable("stepId") String stepId); @RequestMapping(value = "/preparations/steps/{stepId}/metadata", method = GET, produces = APPLICATION_JSON_VALUE) @ApiOperation(value = "Update a preparation steps", notes = "Returns the id of the updated step.") @Timed RowMetadata getStepMetadata(@ApiParam("stepId") @PathVariable("stepId") String stepId); @RequestMapping(value = "/preparations/{id}/steps/copy", method = PUT) @ApiOperation(value = "Copy the steps from another preparation", notes = "Copy the steps from another preparation if this one has no steps.") @Timed void copyStepsFrom(@ApiParam(value = "the preparation id to update") @PathVariable("id") String id,
            @ApiParam(value = "the preparation to copy the steps from.") @RequestParam String from); @RequestMapping(value = "/preparations/{id}/details", method = GET) @ApiOperation(value = "Get preparation details", notes = "Return the details of the preparation with provided id.") @Timed PreparationDTO getDetails( //
            @ApiParam("id") @PathVariable("id") String id, //
            @ApiParam(value = "stepId", defaultValue = "head") @RequestParam(value = "stepId",
                    defaultValue = "head") String stepId); @RequestMapping(value = "/preparations/{id}/details/full", method = GET) @ApiOperation(value = "Get preparation details", notes = "Return the details of the preparation with provided id.") @Timed PreparationDetailsDTO getDetailsFull( //
            @ApiParam("id") @PathVariable("id") String id, //
            @ApiParam(value = "stepId", defaultValue = "head") @RequestParam(value = "stepId",
                    defaultValue = "head") String stepId); @RequestMapping(value = "/preparations/{id}", method = GET) @ApiOperation(value = "Get preparation", notes = "Return the preparation with provided id.") @Timed PreparationDTO get(@ApiParam("id") @PathVariable("id") String id); @RequestMapping(value = "/preparations/{id}/folder", method = GET) @ApiOperation(value = "Get preparation details", notes = "Return the details of the preparation with provided id.") @Timed Folder searchLocation(@ApiParam(value = "the preparation id") @PathVariable("id") String id); @RequestMapping(value = "/preparations/{id}/steps", method = GET) @ApiOperation(value = "Get all preparation steps id", notes = "Return the steps of the preparation with provided id.") @Timed List<String> getSteps(@ApiParam("id") @PathVariable("id") String id); @RequestMapping(value = "/preparations/{id}/actions/{stepId}", method = PUT) @ApiOperation(value = "Updates an action in a preparation", notes = "Modifies an action in preparation's steps.") @Timed void updateAction(@PathVariable("id") final String preparationId,
            @PathVariable("stepId") final String stepToModifyId, @RequestBody final AppendStep newStep); @RequestMapping(value = "/preparations/{id}/actions/{stepId}", method = DELETE) @ApiOperation(value = "Delete an action in a preparation", notes = "Delete a step and all following steps from a preparation") @Timed void deleteAction(@PathVariable("id") final String id, @PathVariable("stepId") final String stepToDeleteId); @RequestMapping(value = "/preparations/{id}/head/{headId}", method = PUT) @ApiOperation(value = "Move preparation head", notes = "Set head to the specified head id") @Timed void setPreparationHead(@PathVariable("id") final String preparationId, //
            @PathVariable("headId") final String headId); @RequestMapping(value = "/preparations/{id}/actions/{version}", method = GET) @ApiOperation(value = "Get all the actions of a preparation at given version.", notes = "Returns the action JSON at version.") @Timed List<Action> getVersionedAction(@ApiParam("id") @PathVariable("id") final String id,
            @ApiParam("version") @PathVariable("version") final String version); @RequestMapping(value = "/preparations/errors", method = RequestMethod.GET) @ApiOperation(value = "Get all preparation related error codes.", notes = "Returns the list of all preparation related error codes.") @Timed Iterable<JsonErrorCodeDescription> listErrors(); @RequestMapping(value = "/preparations/{preparationId}/lock", method = PUT) @ApiOperation(value = "Lock the specified preparation.", notes = "Returns a locked resource.") @Timed void lockPreparation(@ApiParam("preparationId") @PathVariable("preparationId") final String preparationId); @RequestMapping(value = "/preparations/{preparationId}/unlock", method = PUT) @ApiOperation(value = "Unlock the specified preparation.", notes = "Returns a locked resource.") @Timed void unlockPreparation(@ApiParam("preparationId") @PathVariable("preparationId") final String preparationId); @RequestMapping(value = "/preparations/use/dataset/{datasetId}", method = HEAD) @ApiOperation(value = "Check if dataset is used by a preparation.", notes = "Returns no content, the response code is the meaning.") @Timed ResponseEntity<Void> preparationsThatUseDataset(@ApiParam("datasetId") @PathVariable("datasetId") final String datasetId); @RequestMapping(value = "/preparations/{id}/steps/{stepId}/order", method = POST) @ApiOperation(value = "Moves a step within a preparation after a specified step", notes = "Moves a step within a preparation after a specified step.") @Timed void moveStep(@PathVariable("id") final String preparationId,
            @ApiParam(value = "The id of the step we want to move.") @PathVariable String stepId,
            @ApiParam(value = "The step that will become the parent of stepId") @RequestParam String parentStepId); @RequestMapping(value = "/preparations/{id}/actions", method = POST) @ApiOperation(value = "Adds an action at the end of preparation.", notes = "Does not return any value, client may expect successful operation based on HTTP status code.") @Timed void addPreparationAction(
            @ApiParam(name = "id", value = "Preparation id.") @PathVariable(value = "id") final String preparationId,
            @ApiParam("Action to add at end of the preparation.") @RequestBody final List<AppendStep> steps); @RequestMapping(value = "/steps/{id}", method = GET) @ApiOperation(value = "Retrieve a specific step.", notes = "Just find the step for this ID.") @Timed Step getStep(@PathVariable("id") final String stepId);  }
@Test public void getDetails() throws Exception { final Preparation preparation = new Preparation("8b6281c5e99c41313a83777c3ab43b06adda9e5c", "1234", Step.ROOT_STEP.id(), versionService.version().getVersionId()); preparation.setCreationDate(0); preparation.setLastModificationDate(12345); repository.add(preparation); final String preparationDetails = when().get("/preparations/{id}/details", preparation.id()).asString(); final InputStream expected = PreparationControllerTest.class.getResourceAsStream("preparation_1234.json"); assertThat(preparationDetails, sameJSONAsFile(expected)); }
@Test public void getDetailsWithSpecificStepIdShouldReturn404WhenStepIdNotFound() throws Exception { final String preparationContent = IOUtils.toString(this.getClass().getResourceAsStream("base_preparation.json"), "UTF-8"); final String preparationId = clientTest.createPreparationWithAPI(preparationContent); try { clientTest.getDetails(preparationId, "toutouyoutou"); fail("well done, you managed to get the details out of an unknown step !"); } catch (MockTDPException e) { assertEquals(404, e.getStatusCode()); } }