ProxyModeToggle implements ApplicationListener<ContextRefreshedEvent> { @Override public void onApplicationEvent(final ContextRefreshedEvent event) { PropertyDto properties = configurationAccess.getProperties(); OperationMode operationMode = properties.getOperationMode(); if (operationMode == OperationMode.PROXY) { switchProxyModeOn(); } }  @Override void onApplicationEvent(final ContextRefreshedEvent event); void switchProxyModeOn(); void switchProxyModeOff(); boolean isProxyModeOn();  }
@Test public void testOnApplicationEventWhenModeIsProxyShouldSwitchProxyModeOn() { OperationMode operationMode = OperationMode.PROXY; PropertyDto properties = builder.operationMode(operationMode).build(); given(configurationAccess.getProperties()).willReturn(properties); given(requestProcessor.containsProcessor(routerProcessor)).willReturn(true); given(requestProcessor.isProcessorEnabled(routerProcessor)).willReturn(true); underTest.onApplicationEvent(event); verify(requestProcessor).disableProcessor(routerProcessor); }
@Test public void testInitOperationModeWhenModeIsNotProxyShouldDoNothing() { OperationMode operationMode = OperationMode.WILMA; PropertyDto properties = builder.operationMode(operationMode).build(); given(configurationAccess.getProperties()).willReturn(properties); given(requestProcessor.containsProcessor(routerProcessor)).willReturn(false); underTest.onApplicationEvent(event); verify(requestProcessor, never()).disableProcessor(routerProcessor); }