@Test public void testMap() throws Exception { Configuration conf = new Configuration(); conf.set(EXPORT_ACTION_BUILDER_FACTORY_CLASSNAME, "eu.dnetlib.iis.wf.export.actionmanager.sequencefile.MockDocumentProjectActionBuilderFactory"); doReturn(conf).when(context).getConfiguration(); mapper.setup(context); DocumentToProject docToProj = DocumentToProject.newBuilder() .setDocumentId("docId").setProjectId("projId").setConfidenceLevel(0.9f).build(); mapper.map(new AvroKey<DocumentToProject>(docToProj), null, context); verify(context, times(1)).write(keyCaptor.capture(), valueCaptor.capture()); assertTrue(StringUtils.isBlank(keyCaptor.getValue().toString())); AtomicAction expectedAction = new AtomicAction<>(); expectedAction.setClazz(Relation.class); expectedAction.setPayload(MockDocumentProjectActionBuilderFactory.buildRelation(docToProj)); assertEquals(new ObjectMapper().writeValueAsString(expectedAction), valueCaptor.getValue().toString()); }
@Override protected void map(AvroKey<? extends SpecificRecordBase> key, NullWritable ignore, Context context) throws IOException, InterruptedException { List<AtomicAction<Oaf>> actions = createActions(key.datum()); if (actions != null) { for (AtomicAction<Oaf> action : actions) { Text keyOut = new Text(); Text valueOut = new Text(); keyOut.set(""); valueOut.set(ActionSerializationUtils.serializeAction(action, objectMapper)); context.write(keyOut, valueOut); } } }
SequenceFileExporterMapper extends Mapper<AvroKey<? extends SpecificRecordBase>, NullWritable, Text, Text> { @Override protected void map(AvroKey<? extends SpecificRecordBase> key, NullWritable ignore, Context context) throws IOException, InterruptedException { List<AtomicAction<Oaf>> actions = createActions(key.datum()); if (actions != null) { for (AtomicAction<Oaf> action : actions) { Text keyOut = new Text(); Text valueOut = new Text(); keyOut.set(""); valueOut.set(ActionSerializationUtils.serializeAction(action, objectMapper)); context.write(keyOut, valueOut); } } } }
SequenceFileExporterMapper extends Mapper<AvroKey<? extends SpecificRecordBase>, NullWritable, Text, Text> { @Override protected void map(AvroKey<? extends SpecificRecordBase> key, NullWritable ignore, Context context) throws IOException, InterruptedException { List<AtomicAction<Oaf>> actions = createActions(key.datum()); if (actions != null) { for (AtomicAction<Oaf> action : actions) { Text keyOut = new Text(); Text valueOut = new Text(); keyOut.set(""); valueOut.set(ActionSerializationUtils.serializeAction(action, objectMapper)); context.write(keyOut, valueOut); } } }  }
SequenceFileExporterMapper extends Mapper<AvroKey<? extends SpecificRecordBase>, NullWritable, Text, Text> { @Override protected void map(AvroKey<? extends SpecificRecordBase> key, NullWritable ignore, Context context) throws IOException, InterruptedException { List<AtomicAction<Oaf>> actions = createActions(key.datum()); if (actions != null) { for (AtomicAction<Oaf> action : actions) { Text keyOut = new Text(); Text valueOut = new Text(); keyOut.set(""); valueOut.set(ActionSerializationUtils.serializeAction(action, objectMapper)); context.write(keyOut, valueOut); } } }   }
SequenceFileExporterMapper extends Mapper<AvroKey<? extends SpecificRecordBase>, NullWritable, Text, Text> { @Override protected void map(AvroKey<? extends SpecificRecordBase> key, NullWritable ignore, Context context) throws IOException, InterruptedException { List<AtomicAction<Oaf>> actions = createActions(key.datum()); if (actions != null) { for (AtomicAction<Oaf> action : actions) { Text keyOut = new Text(); Text valueOut = new Text(); keyOut.set(""); valueOut.set(ActionSerializationUtils.serializeAction(action, objectMapper)); context.write(keyOut, valueOut); } } }    }