@Test public void should_retrieveStrategyId_when_presentInRawDocument() { ObjectNode documentJson = JsonHandler.createObjectNode(); ObjectNode storageJson = JsonHandler.createObjectNode(); storageJson.put("strategyId", "strategyIdValue"); documentJson.set("_storage", storageJson); String extractedStrategyId = MetadataDocumentHelper.getStrategyIdFromRawUnitOrGot(documentJson); assertThat(extractedStrategyId).isEqualTo("strategyIdValue"); }
public static String getStrategyIdFromRawUnitOrGot(JsonNode documentJson) { if (documentJson == null || !documentJson.isObject()) { throw new IllegalArgumentException("Expected object json"); } ObjectNode document = (ObjectNode) documentJson; if (!document.has(STORAGE_KEY) || !document.get(STORAGE_KEY).has(STRATEGY_KEY) || !document.get(STORAGE_KEY).get(STRATEGY_KEY).isTextual()) { throw new IllegalArgumentException("Expected storage/strategy information in MD document"); } return document.get(STORAGE_KEY).get(STRATEGY_KEY).asText(); }
MetadataDocumentHelper { public static String getStrategyIdFromRawUnitOrGot(JsonNode documentJson) { if (documentJson == null || !documentJson.isObject()) { throw new IllegalArgumentException("Expected object json"); } ObjectNode document = (ObjectNode) documentJson; if (!document.has(STORAGE_KEY) || !document.get(STORAGE_KEY).has(STRATEGY_KEY) || !document.get(STORAGE_KEY).get(STRATEGY_KEY).isTextual()) { throw new IllegalArgumentException("Expected storage/strategy information in MD document"); } return document.get(STORAGE_KEY).get(STRATEGY_KEY).asText(); } }
MetadataDocumentHelper { public static String getStrategyIdFromRawUnitOrGot(JsonNode documentJson) { if (documentJson == null || !documentJson.isObject()) { throw new IllegalArgumentException("Expected object json"); } ObjectNode document = (ObjectNode) documentJson; if (!document.has(STORAGE_KEY) || !document.get(STORAGE_KEY).has(STRATEGY_KEY) || !document.get(STORAGE_KEY).get(STRATEGY_KEY).isTextual()) { throw new IllegalArgumentException("Expected storage/strategy information in MD document"); } return document.get(STORAGE_KEY).get(STRATEGY_KEY).asText(); }  }
MetadataDocumentHelper { public static String getStrategyIdFromRawUnitOrGot(JsonNode documentJson) { if (documentJson == null || !documentJson.isObject()) { throw new IllegalArgumentException("Expected object json"); } ObjectNode document = (ObjectNode) documentJson; if (!document.has(STORAGE_KEY) || !document.get(STORAGE_KEY).has(STRATEGY_KEY) || !document.get(STORAGE_KEY).get(STRATEGY_KEY).isTextual()) { throw new IllegalArgumentException("Expected storage/strategy information in MD document"); } return document.get(STORAGE_KEY).get(STRATEGY_KEY).asText(); }  static List<String> getComputedGraphUnitFields(); static List<String> getComputedGraphObjectGroupFields(); static Set<String> getTemporaryUnitFields(); static Set<String> getComputedUnitFields(); static Set<String> getComputedObjectGroupFields(); static void removeComputedFieldsFromUnit(JsonNode unitJson); static void removeComputedFieldsFromObjectGroup(JsonNode objectGroupJson); static String getStrategyIdFromRawUnitOrGot(JsonNode documentJson); static String getStrategyIdFromUnit(JsonNode unitJson); }
MetadataDocumentHelper { public static String getStrategyIdFromRawUnitOrGot(JsonNode documentJson) { if (documentJson == null || !documentJson.isObject()) { throw new IllegalArgumentException("Expected object json"); } ObjectNode document = (ObjectNode) documentJson; if (!document.has(STORAGE_KEY) || !document.get(STORAGE_KEY).has(STRATEGY_KEY) || !document.get(STORAGE_KEY).get(STRATEGY_KEY).isTextual()) { throw new IllegalArgumentException("Expected storage/strategy information in MD document"); } return document.get(STORAGE_KEY).get(STRATEGY_KEY).asText(); }  static List<String> getComputedGraphUnitFields(); static List<String> getComputedGraphObjectGroupFields(); static Set<String> getTemporaryUnitFields(); static Set<String> getComputedUnitFields(); static Set<String> getComputedObjectGroupFields(); static void removeComputedFieldsFromUnit(JsonNode unitJson); static void removeComputedFieldsFromObjectGroup(JsonNode objectGroupJson); static String getStrategyIdFromRawUnitOrGot(JsonNode documentJson); static String getStrategyIdFromUnit(JsonNode unitJson);  }