X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2Ftest%2Fstructures%2FLstItem.java;h=3617ed9fb0d897adaf654ed96f0f98967811d7d2;hb=refs%2Fchanges%2F67%2F8067%2F6;hp=22b1a3adf681a0efd2e38c212024f01255c1b230;hpb=befccf53b65b379b476290f55590f54c7f250ebb;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/structures/LstItem.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/structures/LstItem.java index 22b1a3adf6..3617ed9fb0 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/structures/LstItem.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/structures/LstItem.java @@ -1,6 +1,15 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * 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.controller.sal.restconf.impl.test.structures; -import java.util.*; +import static org.junit.Assert.assertFalse; +import java.util.HashMap; +import java.util.Map; public class LstItem { String lstName; @@ -8,6 +17,7 @@ public class LstItem { Map lfLsts; Map lsts; Map conts; + private int numOfEqualItems = 0; public LstItem() { lfs = new HashMap<>(); @@ -41,11 +51,20 @@ public class LstItem { return this; } + public LstItem addLf(String name, Object value) { + lfs.put(name, new Lf(name, value)); + return this; + } + public void addLfLst(LfLst lfLst) { + assertFalse( "Found multiple leaf list elements for " + lfLst.getName(), + lfLsts.containsKey( lfLst.getName() ) ); lfLsts.put(lfLst.getName(), lfLst); } public void addLst(Lst lst) { + assertFalse( "Found multiple list elements for " + lst.getName(), + lsts.containsKey( lst.getName() ) ); lsts.put(lst.getName(), lst); } @@ -53,6 +72,10 @@ public class LstItem { conts.put(cont.getName(), cont); } + public void incNumOfEqualItems() { + this.numOfEqualItems++; + } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -62,16 +85,35 @@ public class LstItem { return false; } LstItem lstItem = (LstItem) obj; - if (!this.conts.equals(lstItem.conts)) { + if (this.conts == null) { + if (lstItem.conts != null) { + return false; + } + } else if (!this.conts.equals(lstItem.conts)) { + return false; + } + if (this.lfs == null) { + if (lstItem.lfs != null) { + return false; + } + } else if (!this.lfs.equals(lstItem.lfs)) { return false; } - if (!this.lfs.equals(lstItem.lfs)) { + if (this.lfLsts == null) { + if (lstItem.lfLsts != null) { + return false; + } + } else if (!this.lfLsts.equals(lstItem.lfLsts)) { return false; } - if (!this.lfLsts.equals(lstItem.lfLsts)) { + if (this.lsts == null) { + if (lstItem.lsts != null) { + return false; + } + } else if (!this.lsts.equals(lstItem.lsts)) { return false; } - if (!this.lsts.equals(lstItem.lsts)) { + if (this.numOfEqualItems != lstItem.numOfEqualItems) { return false; } return true; @@ -85,6 +127,7 @@ public class LstItem { result = prime * result + ((lfLsts == null) ? 0 : lfLsts.hashCode()); result = prime * result + ((lsts == null) ? 0 : lsts.hashCode()); result = prime * result + ((conts == null) ? 0 : conts.hashCode()); + result = prime * result + numOfEqualItems; return result; }