### Question:
SecRuleEntityDecoder { public static Long getProtocol(SecurityRule secRule) { SecurityRuleAttributes.Protocol protocol = secRule.getProtocol(); if (protocol == null) { return null; } if (protocol.getUint8() != null) { return protocol.getUint8().longValue(); } if (protocol.getIdentityref() != null) { if (protocol.getIdentityref().equals(ProtocolTcp.class)) { return IpProtoClassifierDefinition.TCP_VALUE; } if (protocol.getIdentityref().equals(ProtocolUdp.class)) { return IpProtoClassifierDefinition.UDP_VALUE; } if (protocol.getIdentityref().equals(ProtocolIcmp.class)) { return IpProtoClassifierDefinition.ICMP_VALUE; } if (protocol.getIdentityref().equals(ProtocolIcmpV6.class)) { return IpProtoClassifierDefinition.ICMPv6_VALUE; } } throw new IllegalArgumentException("Neutron Security Rule Protocol value " + protocol + " is not supported."); } private  SecRuleEntityDecoder(); static ContractId getContractId(SecurityRule secRule); static ClassifierInstance getClassifierInstance(SecurityRule secRule); static ActionRef createActionRefFromActionChoice(ActionChoice action); static ClassifierRef getClassifierRef(SecurityRule secRule); static Direction getDirection(SecurityRule secRule); static Clause getClause(SecurityRule secRule); static boolean isEtherTypeOfOneWithinTwo(SecurityRule one, SecurityRule two); static boolean isProtocolOfOneWithinTwo(SecurityRule one, SecurityRule two); static boolean isPortsOfOneWithinTwo(SecurityRule one, SecurityRule two); static Long getEtherType(SecurityRule secRule); static Long getProtocol(SecurityRule secRule);  }### Answer:
@Test public final void testGetProtocol_protoTcp() { SecurityRuleAttributes.Protocol protocolTcp = new SecurityRuleAttributes.Protocol(ProtocolTcp.class); secRuleBuilder.setProtocol(protocolTcp); Assert.assertEquals(IpProtoClassifierDefinition.TCP_VALUE, SecRuleEntityDecoder.getProtocol(secRuleBuilder.build())); }
@Test public final void testGetProtocol_protoUdp() { SecurityRuleAttributes.Protocol protocolUdp = new SecurityRuleAttributes.Protocol(ProtocolUdp.class); secRuleBuilder.setProtocol(protocolUdp); Assert.assertEquals(IpProtoClassifierDefinition.UDP_VALUE, SecRuleEntityDecoder.getProtocol(secRuleBuilder.build())); }
@Test public final void testGetProtocol_protoIcmp() { SecurityRuleAttributes.Protocol protocolIcmp = new SecurityRuleAttributes.Protocol(ProtocolIcmp.class); secRuleBuilder.setProtocol(protocolIcmp); Assert.assertEquals(IpProtoClassifierDefinition.ICMP_VALUE, SecRuleEntityDecoder.getProtocol(secRuleBuilder.build())); }
@Test public final void testGetProtocol_protoNull() { secRuleBuilder.setProtocol(null); Assert.assertNull(SecRuleEntityDecoder.getProtocol(secRuleBuilder.build())); }
@Test public final void testGetProtocol_protoUnknown() { SecurityRuleAttributes.Protocol protocolUnknown = new SecurityRuleAttributes.Protocol(UnknownProtocol.class); secRuleBuilder.setProtocol(protocolUnknown); thrown.expect(IllegalArgumentException.class); SecRuleEntityDecoder.getProtocol(secRuleBuilder.build()); }