@Test
  public void testGetTaskClassVersion() {
    // cannot find app nor task
    assertEquals(Util.FALLBACK_VERSION, Util.getTaskClassVersion(new MapConfig()));

    // only app
    String appClassVersion = MyAppClass.class.getPackage().getImplementationVersion();
    String expectedAppClassVersion = (appClassVersion != null) ? appClassVersion : Util.FALLBACK_VERSION;
    Config config = new MapConfig(ImmutableMap.of(ApplicationConfig.APP_CLASS, MyAppClass.class.getName()));
    assertEquals(expectedAppClassVersion, Util.getTaskClassVersion(config));

    // only task
    String taskClassVersion = MyTaskClass.class.getPackage().getImplementationVersion();
    String expectedTaskClassVersion = (taskClassVersion != null) ? taskClassVersion : Util.FALLBACK_VERSION;
    config = new MapConfig(ImmutableMap.of(TaskConfig.TASK_CLASS, MyTaskClass.class.getName()));
    assertEquals(expectedTaskClassVersion, Util.getTaskClassVersion(config));

    // both app and task; choose app
    config = new MapConfig(ImmutableMap.of(ApplicationConfig.APP_CLASS, MyAppClass.class.getName(),
        // shouldn't even try to load the task class
        TaskConfig.TASK_CLASS, "this_is_not_a_class"));
    assertEquals(expectedAppClassVersion, Util.getTaskClassVersion(config));
  }
It's difficult to explicitly test having an actual version and using the fallback, due to the usage of methods of
 Class.
samza-core/src/test/java/org/apache/samza/util/TestUtil.java