### Question:
RemoteAssetDecorator implements ResourceDecorator { protected boolean isAlreadySyncing(String resourcePath) { return remoteResourcesSyncing.contains(resourcePath); }  @Override Resource decorate(final Resource resource); @Deprecated @Override Resource decorate(final Resource resource, final HttpServletRequest request);  }### Answer:
@Test public void testGetResourceHandlesExceptionWaitingForSyncInProgress() { when(remoteAssetDecorator.isAlreadySyncing(TEST_REMOTE_ASSET_CONTENT_PATH)).thenReturn(true).thenReturn(true).thenThrow(new RuntimeException("test failed waiting")); setupFinish(); assertResourceDoesNotSync(getUserResourceResolver(), TEST_REMOTE_ASSET_CONTENT_PATH); LogTester.assertLogText("Already sync'ing " + TEST_REMOTE_ASSET_CONTENT_PATH + " - waiting for parallel sync to complete"); LogTester.assertLogText("Failed to wait for parallel binary sync for remote asset: " + TEST_REMOTE_ASSET_CONTENT_PATH); LogTester.assertNotLogText("Parallel sync of " + TEST_REMOTE_ASSET_CONTENT_PATH + " complete"); }
@Test public void testGetResourceWaitsForSyncInProgress() { Resource assetContent = context.resourceResolver().getResource(TEST_REMOTE_ASSET_CONTENT_PATH); when(remoteAssetDecorator.isAlreadySyncing(TEST_REMOTE_ASSET_CONTENT_PATH)).thenReturn(true).thenReturn(true).thenReturn(true) .then(new Answer<Boolean>() { @Override public Boolean answer(InvocationOnMock invocationOnMock) throws Throwable { ModifiableValueMap resourceProps = assetContent.adaptTo(ModifiableValueMap.class); resourceProps.remove(IS_REMOTE_ASSET); resourceProps.put(TEST_MOCK_SYNC, true); return false; } }).thenReturn(false); setupFinish(); Resource resource = getUserResourceResolver().getResource(TEST_REMOTE_ASSET_CONTENT_PATH); LogTester.assertNotLogText("Sync'ing remote asset binaries: " + TEST_REMOTE_ASSET_CONTENT_PATH); assertTrue(resource.getValueMap().get(TEST_MOCK_SYNC, false)); LogTester.assertLogText("Already sync'ing " + TEST_REMOTE_ASSET_CONTENT_PATH + " - waiting for parallel sync to complete"); LogTester.assertLogText("Parallel sync of " + TEST_REMOTE_ASSET_CONTENT_PATH + " complete"); }