@Override public boolean apply(@Nullable Rule input) { return input.getRemoteGroupId() != null && input.getRemoteGroupId().equals(groupId) && input.getProtocol() != null && input.getProtocol().name().equals(ipPermission.getIpProtocol().name()) && input.getPortRangeMin() != null && input.getPortRangeMin() == ipPermission.getFromPort() && input.getPortRangeMax() != null && input.getPortRangeMax() == ipPermission.getToPort(); } })) {
@Override public boolean apply(@Nullable Rule input) { return input.getRemoteGroupId() != null && input.getRemoteGroupId().equals(groupId) && input.getProtocol() != null && input.getProtocol().name().equals(ipPermission.getIpProtocol().name()) && input.getPortRangeMin() != null && input.getPortRangeMin() == ipPermission.getFromPort() && input.getPortRangeMax() != null && input.getPortRangeMax() == ipPermission.getToPort(); } })) {
@Override public IpPermission apply(Rule from) { if (from.getDirection() == RuleDirection.EGRESS) return null; IpPermission.Builder builder = IpPermission.builder(); if (from.getProtocol() != null) { builder.ipProtocol(IpProtocol.fromValue(from.getProtocol().name())); } else { builder.ipProtocol(IpProtocol.TCP); } if (from.getPortRangeMin() != null) builder.fromPort(from.getPortRangeMin()); if (from.getPortRangeMax() != null) builder.toPort(from.getPortRangeMax()); if (from.getRemoteGroupId() != null) { builder.groupId(regionId + "/" + from.getRemoteGroupId()); } else if (from.getRemoteIpPrefix() != null){ builder.cidrBlock(from.getRemoteIpPrefix()); } return builder.build(); } }), Predicates.notNull()));
@Override public IpPermission apply(Rule from) { if (from.getDirection() == RuleDirection.EGRESS) return null; IpPermission.Builder builder = IpPermission.builder(); if (from.getProtocol() != null) { builder.ipProtocol(IpProtocol.fromValue(from.getProtocol().name())); } else { builder.ipProtocol(IpProtocol.TCP); } if (from.getPortRangeMin() != null) builder.fromPort(from.getPortRangeMin()); if (from.getPortRangeMax() != null) builder.toPort(from.getPortRangeMax()); if (from.getRemoteGroupId() != null) { builder.groupId(regionId + "/" + from.getRemoteGroupId()); } else if (from.getRemoteIpPrefix() != null){ builder.cidrBlock(from.getRemoteIpPrefix()); } return builder.build(); } }), Predicates.notNull()));
assertEquals(rule.getEthertype(), RuleEthertype.IPV4); assertEquals(rule.getProtocol(), RuleProtocol.TCP); assertEquals(rule.getRemoteGroupId(), "85cc3048-abc3-43cc-89b3-377341426ac5"); assertEquals(rule.getSecurityGroupId(), "a7734e61-b545-452d-a3cd-0189cbd9747a");