[
https://issues.apache.org/jira/browse/APEXMALHAR-2023?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15256024#comment-15256024
]
ASF GitHub Bot commented on APEXMALHAR-2023:
--------------------------------------------
Github user sandeepdeshmukh commented on a diff in the pull request:
https://github.com/apache/incubator-apex-malhar/pull/235#discussion_r60872509
--- Diff:
contrib/src/test/java/com/datatorrent/contrib/enrich/FileEnrichmentTest.java ---
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.datatorrent.contrib.enrich;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.commons.io.FileUtils;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.google.common.collect.Maps;
+import com.datatorrent.lib.testbench.CollectorTestSink;
+import com.datatorrent.lib.util.TestUtils;
+
+public class FileEnrichmentTest
+{
+
+ @Rule
+ public final TestUtils.TestInfo testInfo = new TestUtils.TestInfo();
+
+ @Test
+ public void testEnrichmentOperator() throws IOException,
InterruptedException
+ {
+ URL origUrl = this.getClass().getResource("/productmapping.txt");
+
+ URL fileUrl = new URL(this.getClass().getResource("/").toString() +
"productmapping1.txt");
+ FileUtils.deleteQuietly(new File(fileUrl.getPath()));
+ FileUtils.copyFile(new File(origUrl.getPath()), new
File(fileUrl.getPath()));
+
+ MapEnricher oper = new MapEnricher();
+ FSLoader store = new FSLoader();
+ store.setFileName(fileUrl.toString());
+ oper.setLookupFields(Arrays.asList("productId"));
+ oper.setIncludeFields(Arrays.asList("productCategory"));
+ oper.setStore(store);
+
+ oper.setup(null);
+
+ /* File contains 6 entries, but operator one entry is duplicate,
+ * so cache should contains only 5 entries after scanning input file.
+ */
+ //Assert.assertEquals("Number of mappings ", 7, oper.cache.size());
+
+ CollectorTestSink<Map<String, Object>> sink = new
CollectorTestSink<>();
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ CollectorTestSink<Object> tmp = (CollectorTestSink)sink;
+ oper.output.setSink(tmp);
+
+ oper.activate(null);
+
+ oper.beginWindow(0);
+ Map<String, Object> tuple = Maps.newHashMap();
+ tuple.put("productId", 3);
+ tuple.put("channelId", 4);
+ tuple.put("amount", 10.0);
+
+ Kryo kryo = new Kryo();
--- End diff --
Is this required?
> Adding Enrichment Operator to Malhar
> ------------------------------------
>
> Key: APEXMALHAR-2023
> URL: https://issues.apache.org/jira/browse/APEXMALHAR-2023
> Project: Apache Apex Malhar
> Issue Type: New Feature
> Components: adapters database
> Affects Versions: 3.3.1
> Reporter: Chinmay Kolhatkar
> Assignee: Chinmay Kolhatkar
>
> Add Enrichment Operator to Apex Malhar.
> Discussion is happening in mailing list here:
> http://mail-archives.apache.org/mod_mbox/incubator-apex-dev/201603.mbox/%3CCAKJfLDMo24-Gcvum2ZL8-0JOnE8QLryAy0Zu_R5zhMd_bsJyHw%40mail.gmail.com%3E
> Ponymail permalink:
> https://pony-poc.apache.org/thread.html/Z8t5ut5pu5vprgt
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)