private void initializeMocks() {
      SystemAdmin admin = mock(SystemAdmin.class);
      doAnswer(invocation -> {
        String offset1 = invocation.getArgumentAt(0, String.class);
        String offset2 = invocation.getArgumentAt(1, String.class);

        return Long.compare(Long.parseLong(offset1), Long.parseLong(offset2));
      }).when(admin).offsetComparator(any(), any());
      doAnswer(invocation -> {
        Map<SystemStreamPartition, String> sspToOffsets = invocation.getArgumentAt(0, Map.class);

        return sspToOffsets.entrySet()
            .stream()
            .collect(Collectors.toMap(Map.Entry::getKey, entry -> getOffsetAfter(entry.getValue())));
      }).when(admin).getOffsetsAfter(any());
      doReturn(admin).when(systemAdmins).getSystemAdmin(TEST_SYSTEM);
      doReturn(ScalaJavaUtil.toScalaMap(new HashMap<>())).when(streamMetadataCache).getStreamMetadata(any(), anyBoolean());
    }
This test is for cases, when calls to systemAdmin (e.g., KafkaSystemAdmin's) get-stream-metadata method return null.
samza-core/src/test/java/org/apache/samza/storage/TestTaskSideInputHandler.java