HeartbeatDelegate extends Delegate { @Override public void applyDelegate(Config config) { if (heartbeatMode != null) { config.setHeartbeatMode(heartbeatMode); config.setAddHeartbeatExtension(true); } } HeartbeatDelegate(); HeartbeatMode getHeartbeatMode(); void setHeartbeatMode(HeartbeatMode heartbeatMode); @Override void applyDelegate(Config config);  }
@Test public void testApplyDelegate() { Config config = Config.createConfig(); config.setHeartbeatMode(null); args = new String[2]; args[0] = "-heartbeat_mode"; args[1] = "PEER_ALLOWED_TO_SEND"; jcommander.parse(args); assertFalse(config.isAddHeartbeatExtension()); delegate.applyDelegate(config); assertTrue(config.getHeartbeatMode() == HeartbeatMode.PEER_ALLOWED_TO_SEND); assertTrue(config.isAddHeartbeatExtension()); }
@Test public void testNothingSetNothingChanges() { Config config = Config.createConfig(); Config config2 = Config.createConfig(); delegate.applyDelegate(config); assertTrue(EqualsBuilder.reflectionEquals(config, config2, "keyStore", "ourCertificate")); }