Search in sources :

Example 11 with ConfigApplyDelegate

use of org.onosproject.net.config.ConfigApplyDelegate in project onos by opennetworkinglab.

the class SuppressionConfigTest method setUp.

@Before
public void setUp() throws Exception {
    ConfigApplyDelegate delegate = config -> {
    };
    ObjectMapper mapper = new ObjectMapper();
    cfg = new SuppressionConfig();
    cfg.init(APP_ID, LldpLinkProvider.CONFIG_KEY, JsonNodeFactory.instance.objectNode(), mapper, delegate);
}
Also used : Device(org.onosproject.net.Device) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) TestApplicationId(org.onosproject.TestApplicationId) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Set(java.util.Set) Test(org.junit.Test) HashMap(java.util.HashMap) HashSet(java.util.HashSet) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) Map(java.util.Map) Assert(org.junit.Assert) DeviceId(org.onosproject.net.DeviceId) Before(org.junit.Before) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) Before(org.junit.Before)

Example 12 with ConfigApplyDelegate

use of org.onosproject.net.config.ConfigApplyDelegate in project onos by opennetworkinglab.

the class SnmpDeviceProviderTest method setUp.

@Before
public void setUp() throws Exception {
    provider.controller = controller;
    provider.providerRegistry = providerRegistry;
    provider.deviceService = deviceService;
    provider.netCfgService = netCfgService;
    provider.deviceStore = deviceStore;
    provider.coreService = coreService;
    JsonNode jsonNode = mapper.readTree(jsonStream);
    ConfigApplyDelegate delegate = new MockDelegate();
    config.init(deviceId, KEY, jsonNode, mapper, delegate);
    provider.activate(null);
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) Before(org.junit.Before)

Example 13 with ConfigApplyDelegate

use of org.onosproject.net.config.ConfigApplyDelegate in project onos by opennetworkinglab.

the class BasicFeatureConfigTest method basicTest.

@Test
public void basicTest() {
    ConfigApplyDelegate delegate = configApply -> {
    };
    ObjectMapper mapper = new ObjectMapper();
    TestConfig enabled = new TestConfig(true);
    TestConfig disabled = new TestConfig(false);
    enabled.init("enabled", "KEY", JsonNodeFactory.instance.objectNode(), mapper, delegate);
    disabled.init("disabled", "KEY", JsonNodeFactory.instance.objectNode(), mapper, delegate);
    assertThat(enabled.enabled(), is(true));
    assertThat(disabled.enabled(), is(false));
    disabled.enabled(true);
    enabled.enabled(false);
    assertThat(enabled.enabled(), is(false));
    assertThat(disabled.enabled(), is(true));
}
Also used : JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) Matchers.is(org.hamcrest.Matchers.is) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) Test(org.junit.Test)

Example 14 with ConfigApplyDelegate

use of org.onosproject.net.config.ConfigApplyDelegate in project onos by opennetworkinglab.

the class McastConfigTest method setUp.

/**
 * Initialize test related variables.
 *
 * @throws Exception
 */
@Before
public void setUp() throws Exception {
    InputStream jsonStream = McastConfigTest.class.getResourceAsStream("/mcast-config.json");
    InputStream invalidJsonStream = McastConfigTest.class.getResourceAsStream("/mcast-config-invalid.json");
    InputStream jsonStreamForInnerVlan = McastConfigTest.class.getResourceAsStream("/mcast-config-inner.json");
    InputStream invalidJsonStreamForInnerVlan = McastConfigTest.class.getResourceAsStream("/mcast-config-invalid-inner.json");
    ApplicationId subject = APP_ID;
    String key = CoreService.CORE_APP_NAME;
    ObjectMapper mapper = new ObjectMapper();
    JsonNode jsonNode = mapper.readTree(jsonStream);
    JsonNode invalidJsonNode = mapper.readTree(invalidJsonStream);
    JsonNode jsonNodeForInnerVlan = mapper.readTree(jsonStreamForInnerVlan);
    JsonNode invalidJsonNodeForInnerVlan = mapper.readTree(invalidJsonStreamForInnerVlan);
    ConfigApplyDelegate delegate = new MockDelegate();
    config = new McastConfig();
    config.init(subject, key, jsonNode, mapper, delegate);
    invalidConfig = new McastConfig();
    invalidConfig.init(subject, key, invalidJsonNode, mapper, delegate);
    configForInnerVlan = new McastConfig();
    configForInnerVlan.init(subject, key, jsonNodeForInnerVlan, mapper, delegate);
    invalidConfigForInnerVlan = new McastConfig();
    invalidConfigForInnerVlan.init(subject, key, invalidJsonNodeForInnerVlan, mapper, delegate);
}
Also used : InputStream(java.io.InputStream) JsonNode(com.fasterxml.jackson.databind.JsonNode) TestApplicationId(org.onosproject.TestApplicationId) ApplicationId(org.onosproject.core.ApplicationId) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) Before(org.junit.Before)

Example 15 with ConfigApplyDelegate

use of org.onosproject.net.config.ConfigApplyDelegate in project onos by opennetworkinglab.

the class AllowedEntityConfigTest method basicTest.

@Test
public void basicTest() {
    ConfigApplyDelegate delegate = configApply -> {
    };
    ObjectMapper mapper = new ObjectMapper();
    TestConfig allowed = new TestConfig();
    TestConfig notAllowed = new TestConfig();
    allowed.init("enabled", "KEY", JsonNodeFactory.instance.objectNode(), mapper, delegate);
    notAllowed.init("disabled", "KEY", JsonNodeFactory.instance.objectNode(), mapper, delegate);
    notAllowed.isAllowed(false);
    assertThat(allowed.isAllowed(), is(true));
    assertThat(notAllowed.isAllowed(), is(false));
    notAllowed.isAllowed(true);
    allowed.isAllowed(false);
    assertThat(allowed.isAllowed(), is(false));
    assertThat(notAllowed.isAllowed(), is(true));
}
Also used : JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) Matchers.is(org.hamcrest.Matchers.is) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConfigApplyDelegate(org.onosproject.net.config.ConfigApplyDelegate) Test(org.junit.Test)

Aggregations

ConfigApplyDelegate (org.onosproject.net.config.ConfigApplyDelegate)22 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)19 JsonNode (com.fasterxml.jackson.databind.JsonNode)16 Before (org.junit.Before)16 Test (org.junit.Test)10 InputStream (java.io.InputStream)7 DeviceId (org.onosproject.net.DeviceId)7 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)6 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)5 Matchers.is (org.hamcrest.Matchers.is)5 TestApplicationId (org.onosproject.TestApplicationId)5 Set (java.util.Set)4 Assert (org.junit.Assert)4 ApplicationId (org.onosproject.core.ApplicationId)4 ConnectPoint (org.onosproject.net.ConnectPoint)4 Map (java.util.Map)3 IpAddress (org.onlab.packet.IpAddress)3 VlanId (org.onlab.packet.VlanId)3 HostId (org.onosproject.net.HostId)3 HostLocation (org.onosproject.net.HostLocation)3