import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
}
public static boolean vlanIdModified(VlanId vlanIdOld, VlanId vlanIdNew) {
- if (vlanIdOld != null && vlanIdNew == null || vlanIdOld == null && vlanIdOld != null) {
- return true;
- }
-
- if (vlanIdOld != null && vlanIdNew != null && !vlanIdOld.equals(vlanIdNew)) {
- return true;
- }
- return false;
+ return !Objects.equals(vlanIdOld, vlanIdNew);
}
}
--- /dev/null
+/*
+ * Copyright © 2017 Red Hat, Inc. and others.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.genius.interfacemanager.renderer.ovs.confighelpers;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+
+/**
+ * Unit tests for {@link OvsVlanMemberConfigUpdateHelper}.
+ */
+public class OvsVlanMemberConfigUpdateHelperTest {
+ @Test
+ public void testVlanIdModified() {
+ VlanId vlanId1 = new VlanId(1);
+ VlanId vlanId2 = new VlanId(2);
+ assertFalse(OvsVlanMemberConfigUpdateHelper.vlanIdModified(null, null));
+ assertTrue(OvsVlanMemberConfigUpdateHelper.vlanIdModified(null, vlanId2));
+ assertTrue(OvsVlanMemberConfigUpdateHelper.vlanIdModified(vlanId1, null));
+ assertFalse(OvsVlanMemberConfigUpdateHelper.vlanIdModified(vlanId1, vlanId1));
+ assertTrue(OvsVlanMemberConfigUpdateHelper.vlanIdModified(vlanId1, vlanId2));
+ }
+}