2 * Copyright © 2024 Smartoptics and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.transportpce.pce.networkanalyzer.port;
12 import java.util.HashMap;
15 import org.junit.jupiter.api.Assertions;
16 import org.junit.jupiter.api.Test;
18 class ClientPreferenceTest {
21 void preferredPort_returnTrue() {
23 Map<String, Set<String>> nodePortPreference = new HashMap<>();
24 nodePortPreference.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
26 Preference clientPreference = new ClientPreference(nodePortPreference);
28 Assertions.assertTrue(clientPreference.isPreferredPort("ROADM-B-SRG1", "SRG1-PP1-TXRX"));
32 * The client prefer to use SRG1-PP1-TXRX on ROADM-B-SRG1.
33 * Therefore, preferredPort returns false on SRG1-PP2-TXRX.
36 void nonPreferredPort_returnFalse() {
38 Map<String, Set<String>> nodePortPreference = new HashMap<>();
39 nodePortPreference.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
41 Preference clientPreference = new ClientPreference(nodePortPreference);
43 Assertions.assertFalse(clientPreference.isPreferredPort("ROADM-B-SRG1", "SRG1-PP2-TXRX"));
47 * In this scenario ROADM-A-SRG1 is missing from the client preferred list.
48 * We treat this as the client has no opinion on what port
49 * to use on ROADM-A-SRG1. Meaning, as far as the client goes, all
50 * ports on ROADM-A-SRG1 are fine.
53 void nodeMissingInPreferredList_returnTrue() {
55 Map<String, Set<String>> nodePortPreference = new HashMap<>();
56 nodePortPreference.put("ROADM-B-SRG1", Set.of("SRG1-PP1-TXRX"));
58 Preference clientPreference = new ClientPreference(nodePortPreference);
60 Assertions.assertTrue(clientPreference.isPreferredPort("ROADM-A-SRG1", "SRG1-PP2-TXRX"));