@Test public void testToAclLineMatchExpr_applicationSet() { ApplicationSet appSet = new ApplicationSet("appSet"); appSet.setMembers( ImmutableList.of(new ApplicationReference("app1"), new ApplicationReference("app2"))); jc.getMasterLogicalSystem().getApplicationSets().put("appSet", appSet); BaseApplication app1 = new BaseApplication("app1"); BaseApplication app2 = new BaseApplication("app2"); jc.getMasterLogicalSystem() .getApplications() .putAll(ImmutableMap.of("app1", app1, "app2", app2)); FwFromApplicationOrApplicationSet from = new FwFromApplicationOrApplicationSet("appSet"); assertEquals( from.toAclLineMatchExpr(jc, null), new OrMatchExpr( ImmutableList.of( new MatchHeaderSpace( HeaderSpace.builder().build(), getTraceElement("host", JuniperStructureType.APPLICATION, "app1")), new MatchHeaderSpace( HeaderSpace.builder().build(), getTraceElement("host", JuniperStructureType.APPLICATION, "app2"))), getTraceElement("host", JuniperStructureType.APPLICATION_SET, "appSet"))); }
@Override public AclLineMatchExpr toAclLineMatchExpr(JuniperConfiguration jc, Warnings w) { ApplicationSetMember application = jc.getMasterLogicalSystem().getApplications().containsKey(_applicationOrApplicationSetName) ? jc.getMasterLogicalSystem().getApplications().get(_applicationOrApplicationSetName) : jc.getMasterLogicalSystem() .getApplicationSets() .get(_applicationOrApplicationSetName); if (application == null) { w.redFlag( String.format( "Reference to undefined application/application-set: %s", _applicationOrApplicationSetName)); return new MatchHeaderSpace( HeaderSpace.builder().setSrcIps(EmptyIpSpace.INSTANCE).build(), ApplicationSetMember.getTraceElement( jc.getFilename(), JuniperStructureType.APPLICATION, _applicationOrApplicationSetName)); } return application.toAclLineMatchExpr(jc, w); }
FwFromApplicationOrApplicationSet implements FwFromApplicationSetMember { @Override public AclLineMatchExpr toAclLineMatchExpr(JuniperConfiguration jc, Warnings w) { ApplicationSetMember application = jc.getMasterLogicalSystem().getApplications().containsKey(_applicationOrApplicationSetName) ? jc.getMasterLogicalSystem().getApplications().get(_applicationOrApplicationSetName) : jc.getMasterLogicalSystem() .getApplicationSets() .get(_applicationOrApplicationSetName); if (application == null) { w.redFlag( String.format( "Reference to undefined application/application-set: %s", _applicationOrApplicationSetName)); return new MatchHeaderSpace( HeaderSpace.builder().setSrcIps(EmptyIpSpace.INSTANCE).build(), ApplicationSetMember.getTraceElement( jc.getFilename(), JuniperStructureType.APPLICATION, _applicationOrApplicationSetName)); } return application.toAclLineMatchExpr(jc, w); } }
FwFromApplicationOrApplicationSet implements FwFromApplicationSetMember { @Override public AclLineMatchExpr toAclLineMatchExpr(JuniperConfiguration jc, Warnings w) { ApplicationSetMember application = jc.getMasterLogicalSystem().getApplications().containsKey(_applicationOrApplicationSetName) ? jc.getMasterLogicalSystem().getApplications().get(_applicationOrApplicationSetName) : jc.getMasterLogicalSystem() .getApplicationSets() .get(_applicationOrApplicationSetName); if (application == null) { w.redFlag( String.format( "Reference to undefined application/application-set: %s", _applicationOrApplicationSetName)); return new MatchHeaderSpace( HeaderSpace.builder().setSrcIps(EmptyIpSpace.INSTANCE).build(), ApplicationSetMember.getTraceElement( jc.getFilename(), JuniperStructureType.APPLICATION, _applicationOrApplicationSetName)); } return application.toAclLineMatchExpr(jc, w); } FwFromApplicationOrApplicationSet(String applicationOrApplicationSetName); }
FwFromApplicationOrApplicationSet implements FwFromApplicationSetMember { @Override public AclLineMatchExpr toAclLineMatchExpr(JuniperConfiguration jc, Warnings w) { ApplicationSetMember application = jc.getMasterLogicalSystem().getApplications().containsKey(_applicationOrApplicationSetName) ? jc.getMasterLogicalSystem().getApplications().get(_applicationOrApplicationSetName) : jc.getMasterLogicalSystem() .getApplicationSets() .get(_applicationOrApplicationSetName); if (application == null) { w.redFlag( String.format( "Reference to undefined application/application-set: %s", _applicationOrApplicationSetName)); return new MatchHeaderSpace( HeaderSpace.builder().setSrcIps(EmptyIpSpace.INSTANCE).build(), ApplicationSetMember.getTraceElement( jc.getFilename(), JuniperStructureType.APPLICATION, _applicationOrApplicationSetName)); } return application.toAclLineMatchExpr(jc, w); } FwFromApplicationOrApplicationSet(String applicationOrApplicationSetName); @Override void applyTo(
      JuniperConfiguration jc,
      HeaderSpace.Builder srcHeaderSpaceBuilder,
      LineAction action,
      List<? super ExprAclLine> lines,
      Warnings w); @Override AclLineMatchExpr toAclLineMatchExpr(JuniperConfiguration jc, Warnings w); }
FwFromApplicationOrApplicationSet implements FwFromApplicationSetMember { @Override public AclLineMatchExpr toAclLineMatchExpr(JuniperConfiguration jc, Warnings w) { ApplicationSetMember application = jc.getMasterLogicalSystem().getApplications().containsKey(_applicationOrApplicationSetName) ? jc.getMasterLogicalSystem().getApplications().get(_applicationOrApplicationSetName) : jc.getMasterLogicalSystem() .getApplicationSets() .get(_applicationOrApplicationSetName); if (application == null) { w.redFlag( String.format( "Reference to undefined application/application-set: %s", _applicationOrApplicationSetName)); return new MatchHeaderSpace( HeaderSpace.builder().setSrcIps(EmptyIpSpace.INSTANCE).build(), ApplicationSetMember.getTraceElement( jc.getFilename(), JuniperStructureType.APPLICATION, _applicationOrApplicationSetName)); } return application.toAclLineMatchExpr(jc, w); } FwFromApplicationOrApplicationSet(String applicationOrApplicationSetName); @Override void applyTo(
      JuniperConfiguration jc,
      HeaderSpace.Builder srcHeaderSpaceBuilder,
      LineAction action,
      List<? super ExprAclLine> lines,
      Warnings w); @Override AclLineMatchExpr toAclLineMatchExpr(JuniperConfiguration jc, Warnings w);  }