Search in sources :

Example 16 with MaintenanceDomain

use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain in project onos by opennetworkinglab.

the class MaintenanceDomainCodecTest method testDecodeMd1NoTypeGiven.

@Test
public void testDecodeMd1NoTypeGiven() throws IOException {
    String mdString = "{\"md\": {    \"mdName\": \"test-1\"," + "\"mdLevel\": \"LEVEL1\", \"mdNumericId\": 1}}";
    InputStream input = new ByteArrayInputStream(mdString.getBytes(StandardCharsets.UTF_8));
    JsonNode cfg = mapper.readTree(input);
    MaintenanceDomain mdDecode1 = context.codec(MaintenanceDomain.class).decode((ObjectNode) cfg, context);
    assertEquals(MDID1_CHAR, mdDecode1.mdId());
    assertEquals(MaintenanceDomain.MdLevel.LEVEL1, mdDecode1.mdLevel());
    assertEquals(1, mdDecode1.mdNumericId());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DefaultMaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain) MaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 17 with MaintenanceDomain

use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain in project onos by opennetworkinglab.

the class MaintenanceDomainCodecTest method testDecodeMd4.

@Test
public void testDecodeMd4() throws IOException {
    String mdString = "{\"md\": {    \"mdName\": \"\"," + "\"mdNameType\": \"NONE\"}}";
    InputStream input = new ByteArrayInputStream(mdString.getBytes(StandardCharsets.UTF_8));
    JsonNode cfg = mapper.readTree(input);
    MaintenanceDomain mdDecode1 = context.codec(MaintenanceDomain.class).decode((ObjectNode) cfg, context);
    assertEquals(MDID4_NONE, mdDecode1.mdId());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DefaultMaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain) MaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 18 with MaintenanceDomain

use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain in project onos by opennetworkinglab.

the class MaintenanceDomainCodecTest method testEncodeMd1.

@Test
public void testEncodeMd1() throws CfmConfigException {
    MaintenanceDomain md1 = DefaultMaintenanceDomain.builder(MDID1_CHAR).mdLevel(MaintenanceDomain.MdLevel.LEVEL1).mdNumericId((short) 1).build();
    ObjectNode node = mapper.createObjectNode();
    node.set("md", context.codec(MaintenanceDomain.class).encode(md1, context));
    assertEquals("{\"md\":{" + "\"mdName\":\"test-1\"," + "\"mdNameType\":\"CHARACTERSTRING\"," + "\"mdLevel\":\"LEVEL1\"," + "\"mdNumericId\":1," + "\"maList\":[]}}", node.toString());
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultMaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain) MaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain) Test(org.junit.Test)

Example 19 with MaintenanceDomain

use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain in project onos by opennetworkinglab.

the class MaintenanceDomainCodecTest method testEncodeMd4.

@Test
public void testEncodeMd4() throws CfmConfigException {
    MaintenanceDomain md4 = DefaultMaintenanceDomain.builder(MDID4_NONE).mdLevel(MaintenanceDomain.MdLevel.LEVEL4).build();
    ObjectNode node = mapper.createObjectNode();
    node.set("md", context.codec(MaintenanceDomain.class).encode(md4, context));
    assertEquals("{\"md\":{" + "\"mdName\":\"\"," + "\"mdNameType\":\"NONE\"," + "\"mdLevel\":\"LEVEL4\"," + "\"maList\":[]}}", node.toString());
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultMaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain) MaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain) Test(org.junit.Test)

Example 20 with MaintenanceDomain

use of org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain in project onos by opennetworkinglab.

the class MaintenanceDomainCodecTest method testDecodeMd3.

@Test
public void testDecodeMd3() throws IOException {
    String mdString = "{\"md\": {    \"mdName\": \"aa:bb:cc:dd:ee:ff:181\"," + "\"mdNameType\": \"MACANDUINT\"}}";
    InputStream input = new ByteArrayInputStream(mdString.getBytes(StandardCharsets.UTF_8));
    JsonNode cfg = mapper.readTree(input);
    MaintenanceDomain mdDecode1 = context.codec(MaintenanceDomain.class).decode((ObjectNode) cfg, context);
    assertEquals(MDID3_MACUINT, mdDecode1.mdId());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DefaultMaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain) MaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Aggregations

MaintenanceDomain (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain)25 DefaultMaintenanceDomain (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain)18 Test (org.junit.Test)16 JsonNode (com.fasterxml.jackson.databind.JsonNode)10 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)10 MaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 Consumes (javax.ws.rs.Consumes)7 Produces (javax.ws.rs.Produces)7 CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)6 CfmMdService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 InputStream (java.io.InputStream)5 WebTarget (javax.ws.rs.client.WebTarget)5 Response (javax.ws.rs.core.Response)5 DefaultMaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation)5 MdId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId)5 Path (javax.ws.rs.Path)4 CfmCodecContext (org.onosproject.cfm.CfmCodecContext)4 PUT (javax.ws.rs.PUT)3