### Question:
GlobalCachingProctorStore implements ProctorStore { @Override public TestDefinition getCurrentTestDefinition(final String test) throws StoreException { final Optional<TestDefinition> cachedDefinitionOpt = globalCacheStore.getCachedTestDefinition(environment, test); if (cachedDefinitionOpt.isPresent()) { return cachedDefinitionOpt.get(); } return delegate.getCurrentTestDefinition(test); } GlobalCachingProctorStore(final ProctorStore delegate,
                                     final GlobalCacheStore globalCacheStore,
                                     final Environment environment
    ); @Override String getName(); @Override TestMatrixVersion getCurrentTestMatrix(); @Override TestDefinition getCurrentTestDefinition(final String test); @Override void verifySetup(); @Override boolean cleanUserWorkspace(final String username); @Override void updateTestDefinition(
            final ChangeMetadata changeMetadata,
            final String previousVersion,
            final String testName,
            final TestDefinition testDefinition,
            final Map<String, String> metadata
    ); @Override void deleteTestDefinition(
            final ChangeMetadata changeMetadata,
            final String previousVersion,
            final String testName,
            final TestDefinition testDefinition
    ); @Override void addTestDefinition(
            final ChangeMetadata changeMetadata,
            final String testName,
            final TestDefinition testDefinition,
            final Map<String, String> metadata
    ); @Nonnull @Override String getLatestVersion(); @Override TestMatrixVersion getTestMatrix(final String fetchRevision); @Override TestDefinition getTestDefinition(final String test, final String fetchRevision); @Nonnull @Override List<Revision> getMatrixHistory(final int start, final int limit); @Nonnull @Override List<Revision> getMatrixHistory(final Instant sinceInclusive, final Instant untilExclusive); @Nonnull @Override List<Revision> getHistory(final String test, final int start, final int limit); @Nonnull @Override List<Revision> getHistory(final String test, final String revision, final int start, final int limit); @CheckForNull @Override RevisionDetails getRevisionDetails(final String revisionId); @Nonnull @Override List<TestEdit> getTestEdits(final String testName, final int start, final int limit); @Nonnull @Override List<TestEdit> getTestEdits(final String testName, final String revision, final int start, final int limit); @Nonnull @Override Map<String, List<Revision>> getAllHistories(); @Override void refresh(); @Override void close();  }### Answer:
@Test public void testGetCurrentTestDefinitionWhenGlobalCacheHas() throws StoreException { when(globalCacheStore.getCachedTestDefinition(Environment.PRODUCTION, TEST_NAME)).thenReturn(Optional.of(TEST_DEFINITION)); final TestDefinition actualTestDefinition = globalCachingProctorStore.getCurrentTestDefinition(TEST_NAME); assertThat(actualTestDefinition).isEqualToComparingFieldByFieldRecursively(TEST_DEFINITION); verifyNoMoreInteractions(delegate); }
@Test public void testGetCurrentTestDefinitionWhenGlobalCacheDoesNotHave() throws StoreException { when(globalCacheStore.getCachedTestDefinition(ENVIRONMENT, TEST_NAME)).thenReturn(Optional.empty()); when(delegate.getCurrentTestDefinition(TEST_NAME)).thenReturn(TEST_DEFINITION); final TestDefinition actualTestDefinition = globalCachingProctorStore.getCurrentTestDefinition(TEST_NAME); assertThat(actualTestDefinition).isEqualToComparingFieldByFieldRecursively(TEST_DEFINITION); }