### Question:
TrimObserver { public void onTrimConfigUpdated(@Observes @TrimConfigUpdated TrimConfig trimConfig) { log.info("Set trim to {} ", trimConfig.isEnableTrim()); this.trimDerivedTablesEnabled = trimConfig.isEnableTrim(); if (trimConfig.isClearTrimQueue()) { synchronized (lock) { trimHeights.clear(); } } } @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 testOnTrimConfigUpdated() { doReturn(5000).when(config).getShardingFrequency(); assertTrue(observer.isTrimDerivedTablesEnabled()); fireBlockPushed(5000); fireBlockPushed(6000); assertEquals(2, observer.getTrimHeights().size()); trimEvent.select(new AnnotationLiteral<TrimConfigUpdated>() { }).fire(new TrimConfig(false, true)); assertFalse(observer.isTrimDerivedTablesEnabled()); assertEquals(0, observer.getTrimHeights().size()); trimEvent.select(new AnnotationLiteral<TrimConfigUpdated>() { }).fire(new TrimConfig(true, false)); assertTrue(observer.isTrimDerivedTablesEnabled()); }