Counter moreThan1Counter = new GenericCounter(); when(reducerContext.getCounter(AvroKeyDedupReducer.EVENT_COUNTER.MORE_THAN_1)).thenReturn(moreThan1Counter); Counter dedupedCounter = new GenericCounter(); when(reducerContext.getCounter(AvroKeyDedupReducer.EVENT_COUNTER.DEDUPED)).thenReturn(dedupedCounter); Counter recordCounter = new GenericCounter(); when(reducerContext.getCounter(AvroKeyDedupReducer.EVENT_COUNTER.RECORD_COUNT)).thenReturn(recordCounter); reducer.setup(reducerContext);
@Override protected Counter newCounter(String name, String displayName, long value) { return new GenericCounter(name, displayName, value); }
@Override public Counter getCounter(String group, String name) { return new GenericCounter(); }
@Override protected Counter newCounter(String name, String displayName, long value) { return new GenericCounter(name, displayName, value); }
@Override protected Counter newCounter() { return new GenericCounter(); }
@Override protected Counter newCounter(String name, String displayName, long value) { return new GenericCounter(name, displayName, value); }
@Override protected Counter newCounter() { return new GenericCounter(); }
@Override protected Counter newCounter() { return new GenericCounter(); }
@Override protected Counter newCounter(String name, String displayName, long value) { return new GenericCounter(name, displayName, value); }
@Override protected Counter newCounter() { return new GenericCounter(); }
@Override public Counter getCounter(Enum<?> name) { return new GenericCounter(); }
public Counter() { this(new GenericCounter()); }
public Counter() { this(new GenericCounter()); }
public Counter() { this(new GenericCounter()); }
public Counter() { this(new GenericCounter()); }
@Override protected Counter newCounter(String counterName, String displayName, long value) { return new Counter(new GenericCounter(counterName, displayName, value)); }
@Override protected Counter newCounter(String counterName, String displayName, long value) { return new Counter(new GenericCounter(counterName, displayName, value)); }
@Override protected Counter newCounter(String counterName, String displayName, long value) { return new Counter(new GenericCounter(counterName, displayName, value)); }
@Override protected Counter newCounter(String counterName, String displayName, long value) { return new Counter(new GenericCounter(counterName, displayName, value)); }
private Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.Context mockContext(Map<String, Counter> counterMap) throws IOException, InterruptedException { @SuppressWarnings("unchecked") Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Mutation>.Context context = Mockito.mock(Mapper.Context.class); Mockito.doReturn(new TaskAttemptID("", 1, TaskType.MAP, 1, 1)).when(context).getTaskAttemptID(); Mockito.doReturn(dbAdaptor.getGenomeHelper().getConf()).when(context).getConfiguration(); Mockito.doAnswer(invocation -> counterMap.computeIfAbsent(invocation.getArgument(0) + "_" + invocation.getArgument(1), (k) -> new GenericCounter(k, k))) .when(context).getCounter(ArgumentMatchers.anyString(), ArgumentMatchers.anyString()); Mockito.doAnswer(invocation -> counterMap.computeIfAbsent(invocation.getArgument(0).toString(), (k) -> new GenericCounter(k, k))).when(context).getCounter(ArgumentMatchers.any()); Mockito.doAnswer(invocation -> dbAdaptor.getHBaseManager().act(((ImmutableBytesWritable) invocation.getArgument(0)).get(), table -> { table.put(((Put) invocation.getArgument(1))); return 0; })).when(context).write(ArgumentMatchers.any(), ArgumentMatchers.any()); return context; }