Source:
public void setup() throws InjectionException { final Configuration conf = Tang.Factory.getTang().newConfigurationBuilder() .bindNamedParameter(KeyCodecName.class, SerializableCodec.class) .bindImplementation(MemoryStore.class, MemoryStoreImpl.class) .bindNamedParameter(MemoryStoreId.class, Integer.toString(LOCAL_STORE_ID)) .bindNamedParameter(NumInitialEvals.class, Integer.toString(NUM_MEMORY_STORES)) .bindNamedParameter(NumTotalBlocks.class, Integer.toString(NUM_TOTAL_BLOCKS)) .bindNamedParameter(Parameters.MiniBatchSize.class, Integer.toString(MINI_BATCH_SIZE)) .build(); final Injector injector = Tang.Factory.getTang().newInjector(conf); injector.bindVolatileInstance(SpanReceiver.class, mock(SpanReceiver.class)); injector.bindVolatileInstance(ElasticMemoryMsgSender.class, mock(ElasticMemoryMsgSender.class)); injector.bindVolatileInstance(RemoteAccessibleMemoryStore.class, mock(RemoteAccessibleMemoryStore.class)); final BlockResolver<Long> mockBlockResolver = mock(BlockResolver.class); injector.bindVolatileInstance(BlockResolver.class, mockBlockResolver); doAnswer(invocation -> { throw new NotImplementedException(); }).when(mockBlockResolver).resolveBlock(anyLong()); doAnswer(invocation -> { final Long minKey = (Long) invocation.getArguments()[0]; final Long maxKey = (Long) invocation.getArguments()[1]; final Map<Integer, Pair<Long, Long>> blockToKeyRange = new HashMap<>(); assertEquals(minKey, maxKey); blockToKeyRange.put((minKey.intValue() / MAX_BLOCK_SIZE), new Pair<>(minKey, maxKey)); return blockToKeyRange; }).when(mockBlockResolver).resolveBlocksForOrderedKeys(anyLong(), anyLong()); memoryStore = injector.getInstance(MemoryStore.class); operationRouter = injector.getInstance(OperationRouter.class); trainingDataProvider = injector.getInstance(TrainingDataProvider.class); }

Target:
public void setup() throws InjectionException { final Configuration conf = Tang.Factory.getTang().newConfigurationBuilder() .bindNamedParameter(KeyCodecName.class, SerializableCodec.class) .bindImplementation(MemoryStore.class, MemoryStoreImpl.class) .bindImplementation(MoveHandler.class, MemoryStoreImpl.class) .bindNamedParameter(MemoryStoreId.class, Integer.toString(LOCAL_STORE_ID)) .bindNamedParameter(NumInitialEvals.class, Integer.toString(NUM_MEMORY_STORES)) .bindNamedParameter(NumTotalBlocks.class, Integer.toString(NUM_TOTAL_BLOCKS)) .bindNamedParameter(Parameters.MiniBatchSize.class, Integer.toString(MINI_BATCH_SIZE)) .build(); final Injector injector = Tang.Factory.getTang().newInjector(conf); injector.bindVolatileInstance(SpanReceiver.class, mock(SpanReceiver.class)); injector.bindVolatileInstance(ElasticMemoryMsgSender.class, mock(ElasticMemoryMsgSender.class)); injector.bindVolatileInstance(RemoteAccessibleMemoryStore.class, mock(RemoteAccessibleMemoryStore.class)); final BlockResolver<Long> mockBlockResolver = mock(BlockResolver.class); injector.bindVolatileInstance(BlockResolver.class, mockBlockResolver); doAnswer(invocation -> { throw new NotImplementedException(); }).when(mockBlockResolver).resolveBlock(anyLong()); doAnswer(invocation -> { final Long minKey = (Long) invocation.getArguments()[0]; final Long maxKey = (Long) invocation.getArguments()[1]; final Map<Integer, Pair<Long, Long>> blockToKeyRange = new HashMap<>(); assertEquals(minKey, maxKey); blockToKeyRange.put((minKey.intValue() / BLOCK_SIZE), new Pair<>(minKey, maxKey)); return blockToKeyRange; }).when(mockBlockResolver).resolveBlocksForOrderedKeys(anyLong(), anyLong()); memoryStore = injector.getInstance(MemoryStore.class); operationRouter = injector.getInstance(OperationRouter.class); trainingDataProvider = injector.getInstance(TrainingDataProvider.class); moveHandler = injector.getInstance(MoveHandler.class); }