Thomas Vachuska
Committed by Gerrit Code Review

Merge "Add unit test for Instructions class and improve Criteria toString() test"

......@@ -119,7 +119,7 @@ public abstract class L2ModificationInstruction implements Instruction {
*/
public static final class ModVlanIdInstruction extends L2ModificationInstruction {
public final VlanId vlanId;
private final VlanId vlanId;
public ModVlanIdInstruction(VlanId vlanId) {
this.vlanId = vlanId;
......@@ -168,7 +168,7 @@ public abstract class L2ModificationInstruction implements Instruction {
*/
public static final class ModVlanPcpInstruction extends L2ModificationInstruction {
public final Byte vlanPcp;
private final Byte vlanPcp;
public ModVlanPcpInstruction(Byte vlanPcp) {
this.vlanPcp = vlanPcp;
......
......@@ -116,7 +116,7 @@ public class CriteriaTest {
private <T> T checkAndConvert(Criterion criterion, Criterion.Type type, Class clazz) {
assertThat(criterion, is(notNullValue()));
assertThat(criterion.type(), is(equalTo(type)));
assertThat(criterion, is(instanceOf(clazz)));
assertThat(criterion, instanceOf(clazz));
return (T) criterion;
}
......@@ -131,16 +131,19 @@ public class CriteriaTest {
*/
private <T extends Criterion> void checkEqualsAndToString(T c1, T c1match,
T c2, Class clazz) {
assertThat(c1, is(instanceOf(clazz)));
assertThat(c1match, is(instanceOf(clazz)));
assertThat(c2, is(instanceOf(clazz)));
assertThat(c1, instanceOf(clazz));
assertThat(c1match, instanceOf(clazz));
assertThat(c2, instanceOf(clazz));
assertThat(c1, is(equalTo(c1match)));
assertThat(c1, is(not(equalTo(c2))));
assertThat(c1, is(not(equalTo(new Object()))));
// Make sure the enumerated type appears in the toString() output.
// Make sure the enumerated type appears in the toString() output and
// the toString output is unique.
assertThat(c1.toString(), containsString(c1.type().toString()));
assertThat(c1.toString(), equalTo(c1match.toString()));
assertThat(c1.toString(), not(equalTo(c2.toString())));
}
......
......@@ -192,7 +192,7 @@ public class FlowModBuilderVer10 extends FlowModBuilder {
return factory().actions().setDlSrc(MacAddress.of(eth.mac().toLong()));
case VLAN_ID:
ModVlanIdInstruction vlanId = (ModVlanIdInstruction) l2m;
return factory().actions().setVlanVid(VlanVid.ofVlan(vlanId.vlanId.toShort()));
return factory().actions().setVlanVid(VlanVid.ofVlan(vlanId.vlanId().toShort()));
case VLAN_PCP:
ModVlanPcpInstruction vlanPcp = (ModVlanPcpInstruction) l2m;
return factory().actions().setVlanPcp(VlanPcp.of(vlanPcp.vlanPcp()));
......
......@@ -210,11 +210,11 @@ public class FlowModBuilderVer13 extends FlowModBuilder {
break;
case VLAN_ID:
ModVlanIdInstruction vlanId = (ModVlanIdInstruction) l2m;
oxm = factory().oxms().vlanVid(OFVlanVidMatch.ofVlan(vlanId.vlanId.toShort()));
oxm = factory().oxms().vlanVid(OFVlanVidMatch.ofVlan(vlanId.vlanId().toShort()));
break;
case VLAN_PCP:
ModVlanPcpInstruction vlanPcp = (ModVlanPcpInstruction) l2m;
oxm = factory().oxms().vlanPcp(VlanPcp.of(vlanPcp.vlanPcp));
oxm = factory().oxms().vlanPcp(VlanPcp.of(vlanPcp.vlanPcp()));
break;
default:
log.warn("Unimplemented action type {}.", l2m.subtype());
......