private NeutralRecord createBaseNeutralRecord(String entityType) { NeutralRecord originalRecord = new NeutralRecord(); originalRecord.setRecordType("recordType"); List<Map<String, Object>> rhData = new ArrayList<Map<String, Object>>(); if (entityType.equals("simple")) { Map<String, Object> rhDataElement = new HashMap<String, Object>(); rhDataElement.put("rhId", "rhId1"); rhDataElement.put("rhHash", "rhHash1"); rhData.add(rhDataElement); } else if (entityType.equals("transformed")) { Map<String, Object> rhDataElement = new HashMap<String, Object>(); rhDataElement.put("rhId", "rhId1"); rhDataElement.put("rhHash", "rhHash1"); rhData.add(rhDataElement); rhDataElement = new HashMap<String, Object>(); rhDataElement.put("rhId", "rhId2"); rhDataElement.put("rhHash", "rhHash2"); rhData.add(rhDataElement); rhDataElement = new HashMap<String, Object>(); rhDataElement.put("rhId", "rhId3"); rhDataElement.put("rhHash", "rhHash3"); rhData.add(rhDataElement); } originalRecord.addMetaData("rhData", rhData); originalRecord.addMetaData("rhTenantId", "rhTenantId"); return originalRecord; }
@Test public void testRecordHashIngestedforTransformedEntity() { NeutralRecord originalRecord = createBaseNeutralRecord("transformed"); @SuppressWarnings("unchecked") List<Map<String, Object>> rhData = (List<Map<String, Object>>) originalRecord.getMetaDataByName("rhData"); testRecordHashIngested(originalRecord, rhData.size()); }
private NeutralRecord addRecordHashMetadata(NeutralRecord originalRecord) { @SuppressWarnings("unchecked") List<Map<String, Object>> rhDataList = (List<Map<String, Object>>) originalRecord.getMetaDataByName("rhData"); for (Map<String, Object> rhDataItem : rhDataList) { Map<String, Object> hashData = new HashMap<String, Object>(); hashData.put("id", "id"); hashData.put("hash", "existingRecordHash"); hashData.put("created", new Long(1)); hashData.put("updated", new Long(1)); hashData.put("version", new Integer(1)); hashData.put("tenantId", "tenantId"); rhDataItem.put("rhCurrentHash", hashData); } return originalRecord; }