### Question:
TrimObserver { List<Integer> getTrimHeights() { synchronized (lock) { return new ArrayList<>(trimHeights); } } @Inject  TrimObserver(TrimService trimService, BlockchainConfig blockchainConfig,
                        PropertiesHolder propertiesHolder, Random random,
                        Blockchain blockchain); void onTrimConfigUpdated(@Observes @TrimConfigUpdated TrimConfig trimConfig); void onBlockScanned(@Observes @BlockEvent(BlockEventType.BLOCK_SCANNED) Block block); int onBlockPushed(@Observes @BlockEvent(BlockEventType.BLOCK_PUSHED) Block block);  }### Answer:
@Test void testOnBlockPushedWithDisabledTrim() throws InterruptedException { doReturn(5000).when(config).getShardingFrequency(); fireBlockPushed(4998); fireBlockPushed(4999); fireBlockPushed(5000); fireBlockPushed(6000); assertEquals(2, observer.getTrimHeights().size()); doAnswer(invocation -> { trimEvent.select(new AnnotationLiteral<TrimConfigUpdated>() { }).fire(new TrimConfig(false, false)); return null; }).when(trimService).trimDerivedTables(5000, true); Thread.sleep(4000); verify(trimService, times(1)).isTrimming(); trimEvent.select(new AnnotationLiteral<TrimConfigUpdated>() { }).fire(new TrimConfig(true, false)); }