### Question:
ControlWebsocketHandler { public void initiateControlSignal(Map<String, String> oldConfigMap, Map<String, String> newConfigMap) { Map<String, ChannelHandlerContext> controlMap = WebSocketMap.controlWebsocketMap; ArrayList<String> changedConfigElmtsList = new ArrayList<>(); if (newConfigMap != null && newConfigMap.size() > 0) { for (Map.Entry<String, String> newEntry : newConfigMap.entrySet()) { String newMapKey = newEntry.getKey(); if (!oldConfigMap.containsKey(newMapKey)) { changedConfigElmtsList.add(newMapKey); } else { String newConfigValue = newEntry.getValue(); String oldConfigValue = oldConfigMap.get(newMapKey); if (!newConfigValue.equals(oldConfigValue)) { changedConfigElmtsList.add(newMapKey); } } } } for (String changedConfigElmtId : changedConfigElmtsList) { if (controlMap.containsKey(changedConfigElmtId)) { ChannelHandlerContext ctx = controlMap.get(changedConfigElmtId); WebSocketMap.unackControlSignalsMap.put(ctx, new ControlSignalSentInfo(1, System.currentTimeMillis())); ByteBuf buffer1 = ctx.alloc().buffer(); buffer1.writeByte(OPCODE_CONTROL_SIGNAL); ctx.channel().writeAndFlush(new BinaryWebSocketFrame(buffer1)); } } }  void handle(ChannelHandlerContext ctx, HttpRequest req); void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame); void initiateControlSignal(Map<String, String> oldConfigMap, Map<String, String> newConfigMap);  }### Answer:
@Test public void testInitiateControlSignalWhenOldAndNewConfigMapIsNull() { controlWebsocketHandler.initiateControlSignal(null, null); PowerMockito.verifyStatic(LoggingService.class); LoggingService.logInfo(MODULE_NAME, "Start Helper method to compare the configuration map control signals"); PowerMockito.verifyStatic(LoggingService.class); LoggingService.logInfo(MODULE_NAME, "Finished Helper method to compare the configuration map control signals"); }
@Test public void testInitiateControlSignalWhenControlWebsocketMapHasDifferentValue() { Map<String, String> newConfigMap = new HashMap<>(); newConfigMap.put("log-level", "INFO"); Map<String, String> oldConfigMap = new HashMap<>(); oldConfigMap.put("log-level", "SEVERE"); WebSocketMap.addWebsocket('C', "log-directory", channelHandlerContext); controlWebsocketHandler.initiateControlSignal(oldConfigMap, newConfigMap); PowerMockito.verifyStatic(LoggingService.class); LoggingService.logInfo(MODULE_NAME, "Start Helper method to compare the configuration map control signals"); PowerMockito.verifyStatic(LoggingService.class); LoggingService.logInfo(MODULE_NAME, "Finished Helper method to compare the configuration map control signals"); }
@Test public void testInitiateControlSignalWhenOldAndNewConfigMapHasDifferentValue() { Map<String, String> newConfigMap = new HashMap<>(); newConfigMap.put("log-level", "INFO"); Map<String, String> oldConfigMap = new HashMap<>(); oldConfigMap.put("log-directory", "SEVERE"); WebSocketMap.addWebsocket('C', "log-directory", channelHandlerContext); controlWebsocketHandler.initiateControlSignal(oldConfigMap, newConfigMap); PowerMockito.verifyStatic(LoggingService.class); LoggingService.logInfo(MODULE_NAME, "Start Helper method to compare the configuration map control signals"); PowerMockito.verifyStatic(LoggingService.class); LoggingService.logInfo(MODULE_NAME, "Finished Helper method to compare the configuration map control signals"); }
@Test public void testInitiateControlSignalWhenControlWebsocketMapHasSameValue() { Map<String, String> newConfigMap = new HashMap<>(); newConfigMap.put("log-level", "INFO"); Map<String, String> oldConfigMap = new HashMap<>(); newConfigMap.put("log-level", "SEVERE"); WebSocketMap.addWebsocket('C', "log-level", channelHandlerContext); controlWebsocketHandler.initiateControlSignal(oldConfigMap, newConfigMap); Mockito.verify(channelHandlerContext).alloc(); Mockito.verify(byteBuf).writeByte(Mockito.eq(0xC)); }