### Question:
SecurityRuleService { public SecurityRulesV4Response getDefaultSecurityRules() { SecurityRulesV4Response ret = new SecurityRulesV4Response(); Set<String> defaultGatewayCidrs = defaultGatewayCidr .stream() .filter(StringUtils::isNotBlank) .collect(Collectors.toSet()); if (!defaultGatewayCidrs.isEmpty()) { defaultGatewayCidr.forEach(cloudbreakCidr -> addCidrAndPort(ret, cloudbreakCidr)); } return ret; }  SecurityRulesV4Response getDefaultSecurityRules(); List<SecurityRule> findAllBySecurityGroupId(Long securityGroupId); static final String TCP_PROTOCOL; }### Answer:
@Test public void getDefaultSecurityRulesWhenKnoxIsEnabled() { SecurityRulesV4Response defaultSecurityRules = underTest.getDefaultSecurityRules(); Assert.assertEquals(3, defaultSecurityRules.getGateway().size()); Assert.assertEquals(1, defaultSecurityRules.getCore().size()); Assert.assertTrue(containsServicePort(defaultSecurityRules.getGateway(), "9443")); Assert.assertTrue(containsServicePort(defaultSecurityRules.getGateway(), "443")); Assert.assertTrue(containsServicePort(defaultSecurityRules.getGateway(), "22")); Assert.assertTrue(containsServicePort(defaultSecurityRules.getCore(), "22")); }
@Test public void getDefaultSecurityRulesWhenKnoxIsEnabledAndKnoxPortIsSet() { SecurityRulesV4Response defaultSecurityRules = underTest.getDefaultSecurityRules(); Assert.assertEquals(3, defaultSecurityRules.getGateway().size()); Assert.assertEquals(1, defaultSecurityRules.getCore().size()); Assert.assertTrue(containsServicePort(defaultSecurityRules.getGateway(), "9443")); Assert.assertTrue(containsServicePort(defaultSecurityRules.getGateway(), "443")); Assert.assertTrue(containsServicePort(defaultSecurityRules.getGateway(), "22")); Assert.assertTrue(containsServicePort(defaultSecurityRules.getCore(), "22")); }
@Test public void getDefaultSecurityRulesWhenKnoxIsDisabledAndHttpsPortIsSet() { SecurityRulesV4Response defaultSecurityRules = underTest.getDefaultSecurityRules(); Assert.assertEquals(3, defaultSecurityRules.getGateway().size()); Assert.assertEquals(1, defaultSecurityRules.getCore().size()); Assert.assertTrue(containsServicePort(defaultSecurityRules.getGateway(), "9443")); Assert.assertTrue(containsServicePort(defaultSecurityRules.getGateway(), "443")); Assert.assertTrue(containsServicePort(defaultSecurityRules.getGateway(), "22")); Assert.assertTrue(containsServicePort(defaultSecurityRules.getCore(), "22")); }