@Test public void should_make_explicit_precondition_failed_when_griffin_id_is_not_find() throws Exception { when(adminManagementClient.findGriffin(any())).thenThrow(new AdminManagementClientServerException("Internal Server Error")); HandlerIO handler = mock(HandlerIO.class); WorkerParameters workerParameters = mock(WorkerParameters.class); PreservationRequest preservationRequest = new PreservationRequest(new Select().getFinalSelect(), "id", "BinaryMaster", LAST, "BinaryMaster"); when(handler.getJsonFromWorkspace("preservationRequest")).thenReturn(toJsonNode(preservationRequest)); ItemStatus itemStatus = preservationPreparationPlugin.execute(workerParameters, handler); String expectedEventDetailData = "{\"error\":\"Preconditions Failed : Internal Server Error\"}"; assertThat(itemStatus.getData("eventDetailData").toString()).isEqualTo(expectedEventDetailData); }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { PreservationRequest preservationRequest = loadPreservationRequest(handler); computePreparation(handler, metaDataClient, preservationRequest, param.getRequestId()); return buildItemStatus(PRESERVATION_PREPARATION, StatusCode.OK, createObjectNode().put("query", preservationRequest.getDslQuery().toString())); } catch (Exception e) { LOGGER.error(String.format("Preservation action failed with status [%s]", KO), e); ObjectNode error = createObjectNode().put("error", e.getMessage()); return buildItemStatus(PRESERVATION_PREPARATION, KO, error); } }
PreservationPreparationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { PreservationRequest preservationRequest = loadPreservationRequest(handler); computePreparation(handler, metaDataClient, preservationRequest, param.getRequestId()); return buildItemStatus(PRESERVATION_PREPARATION, StatusCode.OK, createObjectNode().put("query", preservationRequest.getDslQuery().toString())); } catch (Exception e) { LOGGER.error(String.format("Preservation action failed with status [%s]", KO), e); ObjectNode error = createObjectNode().put("error", e.getMessage()); return buildItemStatus(PRESERVATION_PREPARATION, KO, error); } } }
PreservationPreparationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { PreservationRequest preservationRequest = loadPreservationRequest(handler); computePreparation(handler, metaDataClient, preservationRequest, param.getRequestId()); return buildItemStatus(PRESERVATION_PREPARATION, StatusCode.OK, createObjectNode().put("query", preservationRequest.getDslQuery().toString())); } catch (Exception e) { LOGGER.error(String.format("Preservation action failed with status [%s]", KO), e); ObjectNode error = createObjectNode().put("error", e.getMessage()); return buildItemStatus(PRESERVATION_PREPARATION, KO, error); } } PreservationPreparationPlugin(); @VisibleForTesting  PreservationPreparationPlugin(AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory, WorkspaceClientFactory workspaceClientFactory); }
PreservationPreparationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { PreservationRequest preservationRequest = loadPreservationRequest(handler); computePreparation(handler, metaDataClient, preservationRequest, param.getRequestId()); return buildItemStatus(PRESERVATION_PREPARATION, StatusCode.OK, createObjectNode().put("query", preservationRequest.getDslQuery().toString())); } catch (Exception e) { LOGGER.error(String.format("Preservation action failed with status [%s]", KO), e); ObjectNode error = createObjectNode().put("error", e.getMessage()); return buildItemStatus(PRESERVATION_PREPARATION, KO, error); } } PreservationPreparationPlugin(); @VisibleForTesting  PreservationPreparationPlugin(AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory, WorkspaceClientFactory workspaceClientFactory); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); }
PreservationPreparationPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { try (MetaDataClient metaDataClient = metaDataClientFactory.getClient()) { PreservationRequest preservationRequest = loadPreservationRequest(handler); computePreparation(handler, metaDataClient, preservationRequest, param.getRequestId()); return buildItemStatus(PRESERVATION_PREPARATION, StatusCode.OK, createObjectNode().put("query", preservationRequest.getDslQuery().toString())); } catch (Exception e) { LOGGER.error(String.format("Preservation action failed with status [%s]", KO), e); ObjectNode error = createObjectNode().put("error", e.getMessage()); return buildItemStatus(PRESERVATION_PREPARATION, KO, error); } } PreservationPreparationPlugin(); @VisibleForTesting  PreservationPreparationPlugin(AdminManagementClientFactory adminManagementClientFactory,
        MetaDataClientFactory metaDataClientFactory, WorkspaceClientFactory workspaceClientFactory); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler);  }