@Test public void mapToFunctionMap() { Map<String, Object> functionMap = createFunctionMap(); Map<String, Object> resultRecord = new HashMap<>(); addExportAndTableParameters(resultRecord); mapper.mapRecordToFunctionMap(functionMap, resultRecord, createBapiMapping()); assertEquals(4, functionMap.size()); assertEquals(3, castToMap(functionMap.get("IMPORT")).size()); Map<String, Object> exportParams = castToMap(functionMap.get("EXPORT")); assertEquals(3, exportParams.size()); Map<String, Object> exportParam1 = castToMap(exportParams.get("EXPORT_PARAM1")); assertEquals("structField1", exportParam1.get("STRUCT_FIELD1")); assertEquals(2, exportParam1.get("STRUCT_FIELD2")); assertEquals("exportParam2", exportParams.get("EXPORT_PARAM2")); assertEquals(new Date(3), exportParams.get("EXPORT_PARAM3")); Map<String, Object> changingParams = castToMap(functionMap.get("CHANGING")); assertEquals(2, changingParams.size()); assertEquals("changingParam1-changed", changingParams.get("CHANGING_PARAM1")); assertEquals(22, changingParams.get("CHANGING_PARAM2")); Map<String, Object> tableParams = castToMap(functionMap.get("TABLE")); assertEquals(2, tableParams.size()); List<?> table2 = (List<?>) tableParams.get("TABLE_PARAM2"); assertEquals(2, table2.size()); Map<String, Object> row1 = castToMap(table2.get(0)); assertEquals("tableField1_1", row1.get("TABLE_FIELD1")); assertEquals(12, row1.get("TABLE_FIELD2")); Map<String, Object> row2 = castToMap(table2.get(1)); assertEquals("tableField2_1", row2.get("TABLE_FIELD1")); assertEquals(22, row2.get("TABLE_FIELD2")); }
public void mapRecordToFunctionMap(final Map<String, Object> functionMap, final Map<String, Object> resultRecordMap, final BapiMapping bapiMapping) { LOG.debug("mapRecordToFunctionMap() recordMap=" + resultRecordMap); for (final Entry<String, Object> entry : resultRecordMap.entrySet()) { final Object recordValue = entry.getValue(); final String recordKey = entry.getKey(); if (recordValue != null) { LOG.debug("mapping " + recordValue.getClass().getName() + ": " + recordKey + "=" + recordValue); } if (recordValue instanceof IndexedRecord) { final IndexedRecord indexedResultRecord = (IndexedRecord) recordValue; List<Map<String, Object>> table = new ArrayList<>(); for (Object object : indexedResultRecord) { MappedRecord mr = (MappedRecord) object; final Map<String, Object> line = new HashMap<>(); @SuppressWarnings("unchecked") Set<String> keys = mr.keySet(); for (String key : keys) { line.put(key, mr.get(key)); } table.add(line); } Map<String, Object> tables = UnsafeCastHelper.castToMap(functionMap.get(TABLE)); tables.put(indexedResultRecord.getRecordName(), table); } else { String parameterType = getParameterType(recordKey, bapiMapping); if (isNotBlank(parameterType)) { Map<String, Object> export = UnsafeCastHelper.castToMap(functionMap.get(parameterType)); export.put(recordKey, recordValue); } else { LOG.debug("Skipping unmapped parameter: " + recordKey); } } } LOG.debug("mapRecordToFunctionMap() functionMap=" + functionMap); }
JCAMapper { public void mapRecordToFunctionMap(final Map<String, Object> functionMap, final Map<String, Object> resultRecordMap, final BapiMapping bapiMapping) { LOG.debug("mapRecordToFunctionMap() recordMap=" + resultRecordMap); for (final Entry<String, Object> entry : resultRecordMap.entrySet()) { final Object recordValue = entry.getValue(); final String recordKey = entry.getKey(); if (recordValue != null) { LOG.debug("mapping " + recordValue.getClass().getName() + ": " + recordKey + "=" + recordValue); } if (recordValue instanceof IndexedRecord) { final IndexedRecord indexedResultRecord = (IndexedRecord) recordValue; List<Map<String, Object>> table = new ArrayList<>(); for (Object object : indexedResultRecord) { MappedRecord mr = (MappedRecord) object; final Map<String, Object> line = new HashMap<>(); @SuppressWarnings("unchecked") Set<String> keys = mr.keySet(); for (String key : keys) { line.put(key, mr.get(key)); } table.add(line); } Map<String, Object> tables = UnsafeCastHelper.castToMap(functionMap.get(TABLE)); tables.put(indexedResultRecord.getRecordName(), table); } else { String parameterType = getParameterType(recordKey, bapiMapping); if (isNotBlank(parameterType)) { Map<String, Object> export = UnsafeCastHelper.castToMap(functionMap.get(parameterType)); export.put(recordKey, recordValue); } else { LOG.debug("Skipping unmapped parameter: " + recordKey); } } } LOG.debug("mapRecordToFunctionMap() functionMap=" + functionMap); } }
JCAMapper { public void mapRecordToFunctionMap(final Map<String, Object> functionMap, final Map<String, Object> resultRecordMap, final BapiMapping bapiMapping) { LOG.debug("mapRecordToFunctionMap() recordMap=" + resultRecordMap); for (final Entry<String, Object> entry : resultRecordMap.entrySet()) { final Object recordValue = entry.getValue(); final String recordKey = entry.getKey(); if (recordValue != null) { LOG.debug("mapping " + recordValue.getClass().getName() + ": " + recordKey + "=" + recordValue); } if (recordValue instanceof IndexedRecord) { final IndexedRecord indexedResultRecord = (IndexedRecord) recordValue; List<Map<String, Object>> table = new ArrayList<>(); for (Object object : indexedResultRecord) { MappedRecord mr = (MappedRecord) object; final Map<String, Object> line = new HashMap<>(); @SuppressWarnings("unchecked") Set<String> keys = mr.keySet(); for (String key : keys) { line.put(key, mr.get(key)); } table.add(line); } Map<String, Object> tables = UnsafeCastHelper.castToMap(functionMap.get(TABLE)); tables.put(indexedResultRecord.getRecordName(), table); } else { String parameterType = getParameterType(recordKey, bapiMapping); if (isNotBlank(parameterType)) { Map<String, Object> export = UnsafeCastHelper.castToMap(functionMap.get(parameterType)); export.put(recordKey, recordValue); } else { LOG.debug("Skipping unmapped parameter: " + recordKey); } } } LOG.debug("mapRecordToFunctionMap() functionMap=" + functionMap); }  }
JCAMapper { public void mapRecordToFunctionMap(final Map<String, Object> functionMap, final Map<String, Object> resultRecordMap, final BapiMapping bapiMapping) { LOG.debug("mapRecordToFunctionMap() recordMap=" + resultRecordMap); for (final Entry<String, Object> entry : resultRecordMap.entrySet()) { final Object recordValue = entry.getValue(); final String recordKey = entry.getKey(); if (recordValue != null) { LOG.debug("mapping " + recordValue.getClass().getName() + ": " + recordKey + "=" + recordValue); } if (recordValue instanceof IndexedRecord) { final IndexedRecord indexedResultRecord = (IndexedRecord) recordValue; List<Map<String, Object>> table = new ArrayList<>(); for (Object object : indexedResultRecord) { MappedRecord mr = (MappedRecord) object; final Map<String, Object> line = new HashMap<>(); @SuppressWarnings("unchecked") Set<String> keys = mr.keySet(); for (String key : keys) { line.put(key, mr.get(key)); } table.add(line); } Map<String, Object> tables = UnsafeCastHelper.castToMap(functionMap.get(TABLE)); tables.put(indexedResultRecord.getRecordName(), table); } else { String parameterType = getParameterType(recordKey, bapiMapping); if (isNotBlank(parameterType)) { Map<String, Object> export = UnsafeCastHelper.castToMap(functionMap.get(parameterType)); export.put(recordKey, recordValue); } else { LOG.debug("Skipping unmapped parameter: " + recordKey); } } } LOG.debug("mapRecordToFunctionMap() functionMap=" + functionMap); }  MappedRecord mapFunctionMapValuesToMappedRecord(final String bapiName,
                                                           final RecordFactory recordFactory,
                                                           final Map<String, Object> functionMap); void mapRecordToFunctionMap(final Map<String, Object> functionMap,
                                       final Map<String, Object> resultRecordMap,
                                       final BapiMapping bapiMapping); }
JCAMapper { public void mapRecordToFunctionMap(final Map<String, Object> functionMap, final Map<String, Object> resultRecordMap, final BapiMapping bapiMapping) { LOG.debug("mapRecordToFunctionMap() recordMap=" + resultRecordMap); for (final Entry<String, Object> entry : resultRecordMap.entrySet()) { final Object recordValue = entry.getValue(); final String recordKey = entry.getKey(); if (recordValue != null) { LOG.debug("mapping " + recordValue.getClass().getName() + ": " + recordKey + "=" + recordValue); } if (recordValue instanceof IndexedRecord) { final IndexedRecord indexedResultRecord = (IndexedRecord) recordValue; List<Map<String, Object>> table = new ArrayList<>(); for (Object object : indexedResultRecord) { MappedRecord mr = (MappedRecord) object; final Map<String, Object> line = new HashMap<>(); @SuppressWarnings("unchecked") Set<String> keys = mr.keySet(); for (String key : keys) { line.put(key, mr.get(key)); } table.add(line); } Map<String, Object> tables = UnsafeCastHelper.castToMap(functionMap.get(TABLE)); tables.put(indexedResultRecord.getRecordName(), table); } else { String parameterType = getParameterType(recordKey, bapiMapping); if (isNotBlank(parameterType)) { Map<String, Object> export = UnsafeCastHelper.castToMap(functionMap.get(parameterType)); export.put(recordKey, recordValue); } else { LOG.debug("Skipping unmapped parameter: " + recordKey); } } } LOG.debug("mapRecordToFunctionMap() functionMap=" + functionMap); }  MappedRecord mapFunctionMapValuesToMappedRecord(final String bapiName,
                                                           final RecordFactory recordFactory,
                                                           final Map<String, Object> functionMap); void mapRecordToFunctionMap(final Map<String, Object> functionMap,
                                       final Map<String, Object> resultRecordMap,
                                       final BapiMapping bapiMapping);  }