### Question:
SecRuleEntityDecoder { public static Clause getClause(SecurityRule secRule) { checkNotNull(secRule); SubjectName subjectName = SecRuleNameDecoder.getSubjectName(secRule); ClauseBuilder clauseBuilder = new ClauseBuilder() .setSubjectRefs(ImmutableList.of(subjectName)) .setName(SecRuleNameDecoder .getClauseName(secRule)); IpPrefix remoteIpPrefix = secRule.getRemoteIpPrefix(); if (remoteIpPrefix != null) { clauseBuilder.setConsumerMatchers(createConsumerMatchersWithEic(remoteIpPrefix)); } return clauseBuilder.build(); } 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 testGetClause_noRemoteIpPrefix() { secRuleBuilder.setDirection(DirectionIngress.class); secRuleBuilder.setEthertype(EthertypeV4.class); ClauseName expectedClauseName = SecRuleNameDecoder.getClauseName(secRuleBuilder.build()); Clause clause = SecRuleEntityDecoder.getClause(secRuleBuilder.build()); Assert.assertEquals(expectedClauseName, clause.getName()); List<SubjectName> subjectRefs = clause.getSubjectRefs(); Assert.assertNotNull(subjectRefs); Assert.assertEquals(1, subjectRefs.size()); SubjectName subjectNameFromClause = subjectRefs.get(0); SubjectName expectedSubjectName = SecRuleNameDecoder.getSubjectName(secRuleBuilder.build()); Assert.assertEquals(expectedSubjectName, subjectNameFromClause); Assert.assertNull(clause.getConsumerMatchers()); Assert.assertNull(clause.getProviderMatchers()); }
@Test public final void testGetClause_remoteIpPrefix() { secRuleBuilder.setDirection(DirectionIngress.class); secRuleBuilder.setEthertype(EthertypeV4.class); secRuleBuilder.setRemoteIpPrefix(new IpPrefix(new Ipv4Prefix("10.0.0.0/8"))); Clause clause = SecRuleEntityDecoder.getClause(secRuleBuilder.build()); ClauseName expectedClauseName = SecRuleNameDecoder.getClauseName(secRuleBuilder.build()); Assert.assertEquals(expectedClauseName, clause.getName()); List<SubjectName> subjectRefs = clause.getSubjectRefs(); Assert.assertNotNull(subjectRefs); Assert.assertEquals(1, subjectRefs.size()); SubjectName subjectNameFromClause = subjectRefs.get(0); SubjectName expectedSubjectName = SecRuleNameDecoder.getSubjectName(secRuleBuilder.build()); Assert.assertEquals(expectedSubjectName, subjectNameFromClause); Assert.assertNull(clause.getProviderMatchers()); ConsumerMatchers consumerMatchers = clause.getConsumerMatchers(); Assert.assertNotNull(consumerMatchers); Assert.assertNull(consumerMatchers.getConditionMatcher()); Assert.assertNull(consumerMatchers.getGroupIdentificationConstraints()); EndpointIdentificationConstraints endpointIdentificationConstraints = consumerMatchers.getEndpointIdentificationConstraints(); Assert.assertNotNull(endpointIdentificationConstraints); L3EndpointIdentificationConstraints l3EndpointIdentificationConstraints = endpointIdentificationConstraints.getL3EndpointIdentificationConstraints(); Assert.assertNotNull(l3EndpointIdentificationConstraints); List<PrefixConstraint> prefixConstraints = l3EndpointIdentificationConstraints.getPrefixConstraint(); Assert.assertNotNull(prefixConstraints); Assert.assertEquals(1, prefixConstraints.size()); PrefixConstraint prefixConstraint = prefixConstraints.get(0); Assert.assertEquals(new Ipv4Prefix("10.0.0.0/8"), prefixConstraint.getIpPrefix().getIpv4Prefix()); }