use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class DefaultMappingKeyTest method testEquals.
/**
* Tests equals() method.
*/
@Test
public void testEquals() {
IpPrefix ip1 = IpPrefix.valueOf(IP_ADDRESS_1);
MappingAddress address1 = MappingAddresses.ipv4MappingAddress(ip1);
MappingKey key1 = DefaultMappingKey.builder().withAddress(address1).build();
MappingKey sameAsKey1 = DefaultMappingKey.builder().withAddress(address1).build();
IpPrefix ip2 = IpPrefix.valueOf(IP_ADDRESS_2);
MappingAddress address2 = MappingAddresses.ipv4MappingAddress(ip2);
MappingKey key2 = DefaultMappingKey.builder().withAddress(address2).build();
new EqualsTester().addEqualityGroup(key1, sameAsKey1).addEqualityGroup(key2).testEquals();
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class DefaultMappingTreatmentTest method testBuilderMethods.
/**
* Tests method defined on the Builder.
*/
@Test
public void testBuilderMethods() {
IpPrefix ip = IpPrefix.valueOf(IP_ADDRESS_1);
MappingAddress address = MappingAddresses.ipv4MappingAddress(ip);
MappingTreatment.Builder builder = DefaultMappingTreatment.builder().withAddress(address).setUnicastPriority(10).setUnicastWeight(10);
MappingTreatment treatment = builder.build();
assertThat(treatment.instructions(), hasSize(2));
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class DefaultMappingTreatmentTest method testIllegalUnicastTypeConstruction.
/**
* Tests illegal unicast type instruction construction.
*/
@Test(expected = IllegalArgumentException.class)
public void testIllegalUnicastTypeConstruction() {
IpPrefix ip = IpPrefix.valueOf(IP_ADDRESS_1);
MappingAddress address = MappingAddresses.ipv4MappingAddress(ip);
DefaultMappingTreatment.builder().withAddress(address).setUnicastPriority(10).setUnicastWeight(10).setUnicastPriority(20).build();
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class MappingKeyCodec method encode.
@Override
public ObjectNode encode(MappingKey key, CodecContext context) {
checkNotNull(key, "Mapping key cannot be null");
final ObjectNode result = context.mapper().createObjectNode();
final JsonCodec<MappingAddress> addressCodec = context.codec(MappingAddress.class);
result.set(ADDRESS, addressCodec.encode(key.address(), context));
return result;
}
use of org.onosproject.mapping.addresses.MappingAddress in project onos by opennetworkinglab.
the class MappingAddressCodecTest method ipv6MappingAddressTest.
/**
* Tests IPv6 mapping address.
*/
@Test
public void ipv6MappingAddressTest() {
MappingAddress address = MappingAddresses.ipv6MappingAddress(IPV6_PREFIX);
ObjectNode result = addressCodec.encode(address, context);
assertThat(result, matchesMappingAddress(address));
}
Aggregations