ContextImpl implements Context { @Override public ApplicationTaskContext getApplicationTaskContext() { Preconditions.checkState(this.applicationTaskContextOptional.isPresent(), "No application-defined task context exists"); return this.applicationTaskContextOptional.get(); } ContextImpl(JobContext jobContext, ContainerContext containerContext, TaskContext taskContext,
      Optional<ApplicationContainerContext> applicationContainerContextOptional,
      Optional<ApplicationTaskContext> applicationTaskContextOptional,
      Optional<ExternalContext> externalContextOptional); @Override JobContext getJobContext(); @Override ContainerContext getContainerContext(); @Override TaskContext getTaskContext(); @Override ApplicationContainerContext getApplicationContainerContext(); @Override ApplicationTaskContext getApplicationTaskContext(); @Override ExternalContext getExternalContext(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testGetApplicationTaskContext() { ApplicationTaskContext applicationTaskContext = mock(ApplicationTaskContext.class); Context context = buildWithApplicationTaskContext(applicationTaskContext); assertEquals(applicationTaskContext, context.getApplicationTaskContext()); }
@Test(expected = IllegalStateException.class) public void testGetMissingApplicationTaskContext() { Context context = buildWithApplicationTaskContext(null); context.getApplicationTaskContext(); }