/** * Tests the point to point intent JSON codec. * * @throws IOException if JSON processing fails */ @Test public void decodePointToPointIntent() throws IOException { JsonCodec<Intent> intentCodec = context.codec(Intent.class); assertThat(intentCodec, notNullValue()); Intent intent = getIntent("PointToPointIntent.json", intentCodec); assertThat(intent, notNullValue()); assertThat(intent, instanceOf(PointToPointIntent.class)); PointToPointIntent pointIntent = (PointToPointIntent) intent; assertThat(pointIntent.priority(), is(55)); assertThat(pointIntent.ingressPoint().deviceId(), is(did("0000000000000001"))); assertThat(pointIntent.ingressPoint().port(), is(PortNumber.portNumber(1))); assertThat(pointIntent.egressPoint().deviceId(), is(did("0000000000000007"))); assertThat(pointIntent.egressPoint().port(), is(PortNumber.portNumber(2))); assertThat(pointIntent.constraints(), hasSize(1)); assertThat(pointIntent.selector(), notNullValue()); assertThat(pointIntent.selector().criteria(), hasSize(1)); Criterion criterion1 = pointIntent.selector().criteria().iterator().next(); assertThat(criterion1, instanceOf(EthCriterion.class)); EthCriterion ethCriterion = (EthCriterion) criterion1; assertThat(ethCriterion.mac().toString(), is("11:22:33:44:55:66")); assertThat(ethCriterion.type().name(), is("ETH_DST")); assertThat(pointIntent.treatment(), notNullValue()); assertThat(pointIntent.treatment().allInstructions(), hasSize(1)); Instruction instruction1 = pointIntent.treatment().allInstructions().iterator().next(); assertThat(instruction1, instanceOf(ModEtherInstruction.class)); ModEtherInstruction ethInstruction = (ModEtherInstruction) instruction1; assertThat(ethInstruction.mac().toString(), is("22:33:44:55:66:77")); assertThat(ethInstruction.type().toString(), is("L2MODIFICATION")); assertThat(ethInstruction.subtype().toString(), is("ETH_SRC")); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof ModEtherInstruction) { ModEtherInstruction that = (ModEtherInstruction) obj; return Objects.equals(mac, that.mac) && Objects.equals(this.type(), that.type()) && Objects.equals(subtype, that.subtype); } return false; }