/**
   * Tests vRouterId setter.
   *
   * @throws Exception
   */
  @Test
  public void testSetVRouterId() throws Exception {
    config.setVRouterId(VROUTER_ID_2);

    Optional<DeviceId> vRouterId = config.vRouterId();
    assertTrue(vRouterId.isPresent());
    assertThat(vRouterId.get(), is(VROUTER_ID_2));
  }
  /**
   * Tests vRouterMacs setter.
   *
   * @throws Exception
   */
  @Test
  public void testSetVRouterMacs() throws Exception {
    ImmutableSet.Builder<MacAddress> builder = ImmutableSet.builder();
    builder.add(ROUTER_MAC_3);
    config.setVRouterMacs(builder.build());

    Set<MacAddress> vRouterMacs = config.vRouterMacs();
    assertThat(vRouterMacs.size(), is(1));
    assertTrue(vRouterMacs.contains(ROUTER_MAC_3));
  }
  /**
   * Tests suppressHostByProvider setter.
   *
   * @throws Exception
   */
  @Test
  public void testSetHostLearning() throws Exception {
    ImmutableSet.Builder<String> builder = ImmutableSet.builder();
    builder.add(PROVIDER_3);
    config.setSuppressHostByProvider(builder.build());

    Set<String> supprsuppressHostByProvider = config.suppressHostByProvider();
    assertNotNull("suppressHostByProvider should not be null", supprsuppressHostByProvider);
    assertThat(supprsuppressHostByProvider.size(), is(1));
    assertTrue(supprsuppressHostByProvider.contains(PROVIDER_3));
  }
  /**
   * Tests suppressHostByPort setter.
   *
   * @throws Exception
   */
  @Test
  public void testSetSuppressHostByPort() throws Exception {
    ImmutableSet.Builder<ConnectPoint> builder = ImmutableSet.builder();
    builder.add(PORT_3);
    config.setSuppressHostByPort(builder.build());

    Set<ConnectPoint> suppressHostByPort = config.suppressHostByPort();
    assertNotNull("suppressHostByPort should not be null", suppressHostByPort);
    assertThat(suppressHostByPort.size(), is(1));
    assertTrue(suppressHostByPort.contains(PORT_3));
  }
 /**
  * Tests vRouterMacs getter.
  *
  * @throws Exception
  */
 @Test
 public void testVRouterMacs() throws Exception {
   Set<MacAddress> vRouterMacs = config.vRouterMacs();
   assertNotNull("vRouterMacs should not be null", vRouterMacs);
   assertThat(vRouterMacs.size(), is(2));
   assertTrue(vRouterMacs.contains(ROUTER_MAC_1));
   assertTrue(vRouterMacs.contains(ROUTER_MAC_2));
 }
 /**
  * Tests suppressHostByProvider getter.
  *
  * @throws Exception
  */
 @Test
 public void testSuppressHostByProvider() throws Exception {
   Set<String> supprsuppressHostByProvider = config.suppressHostByProvider();
   assertNotNull("suppressHostByProvider should not be null", supprsuppressHostByProvider);
   assertThat(supprsuppressHostByProvider.size(), is(2));
   assertTrue(supprsuppressHostByProvider.contains(PROVIDER_1));
   assertTrue(supprsuppressHostByProvider.contains(PROVIDER_2));
 }
 /**
  * Tests suppressHostByPort getter.
  *
  * @throws Exception
  */
 @Test
 public void testSuppressHostByPort() throws Exception {
   Set<ConnectPoint> suppressHostByPort = config.suppressHostByPort();
   assertNotNull("suppressHostByPort should not be null", suppressHostByPort);
   assertThat(suppressHostByPort.size(), is(2));
   assertTrue(suppressHostByPort.contains(PORT_1));
   assertTrue(suppressHostByPort.contains(PORT_2));
 }
  /**
   * Initialize test related variables.
   *
   * @throws Exception
   */
  @Before
  public void setUp() throws Exception {
    InputStream jsonStream = SegmentRoutingAppConfigTest.class.getResourceAsStream("/app.json");
    InputStream invalidJsonStream =
        SegmentRoutingAppConfigTest.class.getResourceAsStream("/app-invalid.json");

    String key = SegmentRoutingManager.SR_APP_ID;
    ApplicationId subject = new TestApplicationId(key);
    ObjectMapper mapper = new ObjectMapper();
    JsonNode jsonNode = mapper.readTree(jsonStream);
    JsonNode invalidJsonNode = mapper.readTree(invalidJsonStream);
    ConfigApplyDelegate delegate = new MockDelegate();

    config = new SegmentRoutingAppConfig();
    config.init(subject, key, jsonNode, mapper, delegate);
    invalidConfig = new SegmentRoutingAppConfig();
    invalidConfig.init(subject, key, invalidJsonNode, mapper, delegate);
  }
 /**
  * Tests config validity.
  *
  * @throws Exception
  */
 @Test
 public void testIsValid() throws Exception {
   assertTrue(config.isValid());
   assertFalse(invalidConfig.isValid());
 }