@Test(expected = VitamException.class) public void testBuildAllParentsRefWithMissingUpThrowsVitamException() throws Exception { JsonTransformer.buildAllParentsRef("ID029", invalidParentsWithMissingUp); }
public static ObjectNode buildAllParentsRef(String unitId, JsonNode allParents) throws VitamException { ParametersChecker.checkParameter("Result cannot be empty", allParents); boolean hasUnitId = false; final ObjectNode allParentsRef = JsonHandler.createObjectNode(); for (final JsonNode currentParentNode : allParents) { if (!currentParentNode.has(UiConstants.ID.getResultCriteria())) { throw new VitamException(MISSING_ID_ERROR_MSG); } if (!currentParentNode.has(UiConstants.UNITUPS.getResultCriteria())) { throw new VitamException(MISSING_UP_ERROR_MSG); } if (!currentParentNode.get(UiConstants.UNITUPS.getResultCriteria()).isArray()) { throw new VitamException(INVALID_UP_FIELD_ERROR_MSG); } final String currentParentId = currentParentNode.get(UiConstants.ID.getResultCriteria()).asText(); allParentsRef.set(currentParentId, currentParentNode); if (unitId.equalsIgnoreCase(currentParentId)) { hasUnitId = true; } } if (!hasUnitId) { throw new VitamException(MISSING_UNIT_ID_ERROR_MSG); } return allParentsRef; }
JsonTransformer { public static ObjectNode buildAllParentsRef(String unitId, JsonNode allParents) throws VitamException { ParametersChecker.checkParameter("Result cannot be empty", allParents); boolean hasUnitId = false; final ObjectNode allParentsRef = JsonHandler.createObjectNode(); for (final JsonNode currentParentNode : allParents) { if (!currentParentNode.has(UiConstants.ID.getResultCriteria())) { throw new VitamException(MISSING_ID_ERROR_MSG); } if (!currentParentNode.has(UiConstants.UNITUPS.getResultCriteria())) { throw new VitamException(MISSING_UP_ERROR_MSG); } if (!currentParentNode.get(UiConstants.UNITUPS.getResultCriteria()).isArray()) { throw new VitamException(INVALID_UP_FIELD_ERROR_MSG); } final String currentParentId = currentParentNode.get(UiConstants.ID.getResultCriteria()).asText(); allParentsRef.set(currentParentId, currentParentNode); if (unitId.equalsIgnoreCase(currentParentId)) { hasUnitId = true; } } if (!hasUnitId) { throw new VitamException(MISSING_UNIT_ID_ERROR_MSG); } return allParentsRef; } }
JsonTransformer { public static ObjectNode buildAllParentsRef(String unitId, JsonNode allParents) throws VitamException { ParametersChecker.checkParameter("Result cannot be empty", allParents); boolean hasUnitId = false; final ObjectNode allParentsRef = JsonHandler.createObjectNode(); for (final JsonNode currentParentNode : allParents) { if (!currentParentNode.has(UiConstants.ID.getResultCriteria())) { throw new VitamException(MISSING_ID_ERROR_MSG); } if (!currentParentNode.has(UiConstants.UNITUPS.getResultCriteria())) { throw new VitamException(MISSING_UP_ERROR_MSG); } if (!currentParentNode.get(UiConstants.UNITUPS.getResultCriteria()).isArray()) { throw new VitamException(INVALID_UP_FIELD_ERROR_MSG); } final String currentParentId = currentParentNode.get(UiConstants.ID.getResultCriteria()).asText(); allParentsRef.set(currentParentId, currentParentNode); if (unitId.equalsIgnoreCase(currentParentId)) { hasUnitId = true; } } if (!hasUnitId) { throw new VitamException(MISSING_UNIT_ID_ERROR_MSG); } return allParentsRef; } private  JsonTransformer(); }
JsonTransformer { public static ObjectNode buildAllParentsRef(String unitId, JsonNode allParents) throws VitamException { ParametersChecker.checkParameter("Result cannot be empty", allParents); boolean hasUnitId = false; final ObjectNode allParentsRef = JsonHandler.createObjectNode(); for (final JsonNode currentParentNode : allParents) { if (!currentParentNode.has(UiConstants.ID.getResultCriteria())) { throw new VitamException(MISSING_ID_ERROR_MSG); } if (!currentParentNode.has(UiConstants.UNITUPS.getResultCriteria())) { throw new VitamException(MISSING_UP_ERROR_MSG); } if (!currentParentNode.get(UiConstants.UNITUPS.getResultCriteria()).isArray()) { throw new VitamException(INVALID_UP_FIELD_ERROR_MSG); } final String currentParentId = currentParentNode.get(UiConstants.ID.getResultCriteria()).asText(); allParentsRef.set(currentParentId, currentParentNode); if (unitId.equalsIgnoreCase(currentParentId)) { hasUnitId = true; } } if (!hasUnitId) { throw new VitamException(MISSING_UNIT_ID_ERROR_MSG); } return allParentsRef; } private  JsonTransformer(); static JsonNode transformResultObjects(JsonNode searchResult); static ObjectNode buildAllParentsRef(String unitId, JsonNode allParents); static ByteArrayOutputStream buildLogbookStatCsvFile(JsonNode logbookOperation); }
JsonTransformer { public static ObjectNode buildAllParentsRef(String unitId, JsonNode allParents) throws VitamException { ParametersChecker.checkParameter("Result cannot be empty", allParents); boolean hasUnitId = false; final ObjectNode allParentsRef = JsonHandler.createObjectNode(); for (final JsonNode currentParentNode : allParents) { if (!currentParentNode.has(UiConstants.ID.getResultCriteria())) { throw new VitamException(MISSING_ID_ERROR_MSG); } if (!currentParentNode.has(UiConstants.UNITUPS.getResultCriteria())) { throw new VitamException(MISSING_UP_ERROR_MSG); } if (!currentParentNode.get(UiConstants.UNITUPS.getResultCriteria()).isArray()) { throw new VitamException(INVALID_UP_FIELD_ERROR_MSG); } final String currentParentId = currentParentNode.get(UiConstants.ID.getResultCriteria()).asText(); allParentsRef.set(currentParentId, currentParentNode); if (unitId.equalsIgnoreCase(currentParentId)) { hasUnitId = true; } } if (!hasUnitId) { throw new VitamException(MISSING_UNIT_ID_ERROR_MSG); } return allParentsRef; } private  JsonTransformer(); static JsonNode transformResultObjects(JsonNode searchResult); static ObjectNode buildAllParentsRef(String unitId, JsonNode allParents); static ByteArrayOutputStream buildLogbookStatCsvFile(JsonNode logbookOperation);  }