X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-batch%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fbatch%2Fhelpers%2Ftest%2FJU_NS.java;h=e72b55ea3d7e48e342224b8c5f38c9d9b8901427;hb=6dd9704640eb8cc8d6b4ccd266e40a3f6f589e75;hp=1208ba928b7cc0db31dd00b231d994ab9d5a2466;hpb=613846477296bd3888ba6e5f939afe688b486ad7;p=aaf%2Fauthz.git diff --git a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_NS.java b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_NS.java index 1208ba92..e72b55ea 100644 --- a/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_NS.java +++ b/auth/auth-batch/src/test/java/org/onap/aaf/auth/batch/helpers/test/JU_NS.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -48,112 +48,112 @@ import junit.framework.Assert; public class JU_NS { - NS ns; - NSSplit nSSplit; - - @Before - public void setUp() { - ns = new NS("name", "description", "parent", 1, 1); - nSSplit = new NSSplit("string", 1); - } - - @Test - public void testToString() { - Assert.assertEquals("name", ns.toString()); - } - - @Test - public void testHashCode() { - Assert.assertEquals(3373707, ns.hashCode()); - } - - @Test - public void testEquals() { - Assert.assertEquals(true, ns.equals("name")); - Assert.assertEquals(false, ns.equals("name1")); - } - - @Test - public void testCompareTo() { - NS nsValid = new NS("name", "description", "parent", 1, 1); - Assert.assertEquals(0, ns.compareTo(nsValid)); - - NS nsInvalid = new NS("name1", "description", "parent", 1, 1); - Assert.assertEquals(-1, ns.compareTo(nsInvalid)); - } - - @Test - public void testDeriveParent() { - ns.deriveParent("d.ot.te.d"); - } - - @Test - public void testLoadWithoutNS() { - Trans trans = mock(Trans.class); - Session session = mock(Session.class); - Creator creator = mock(Creator.class); - LogTarget target = mock(LogTarget.class); - TimeTaken tt = mock(TimeTaken.class); - ResultSet results = mock(ResultSet.class); - ArrayList rows = new ArrayList(); - Row row = RowCreator.getRow(); - rows.add(row); - - when(trans.info()).thenReturn(target); - when(trans.start("Read Namespaces", Env.REMOTE)).thenReturn(tt); - when(trans.start("Load Namespaces", Env.SUB)).thenReturn(tt); - when(session.execute(any(SimpleStatement.class))).thenReturn(results); - when(results.iterator()).thenReturn(rows.iterator()); - when(creator.create(row)).thenReturn(ns); - - NS.load(trans, session, creator); - } - - @Test - public void testLoadOne() { - Trans trans = mock(Trans.class); - Session session = mock(Session.class); - Creator creator = mock(Creator.class); - LogTarget target = mock(LogTarget.class); - TimeTaken tt = mock(TimeTaken.class); - ResultSet results = mock(ResultSet.class); - ArrayList rows = new ArrayList(); - Row row = RowCreator.getRow(); - rows.add(row); - - when(trans.info()).thenReturn(target); - when(trans.start("Read Namespaces", Env.REMOTE)).thenReturn(tt); - when(trans.start("Load Namespaces", Env.SUB)).thenReturn(tt); - when(session.execute(any(SimpleStatement.class))).thenReturn(results); - when(results.iterator()).thenReturn(rows.iterator()); - when(creator.create(row)).thenReturn(ns); - - NS.loadOne(trans, session, creator, "text"); - } - - @Test - public void testCount() { - Trans trans = mock(Trans.class); - Session session = mock(Session.class); - LogTarget target = mock(LogTarget.class); - TimeTaken tt = mock(TimeTaken.class); - ResultSet results = mock(ResultSet.class); - ArrayList rows = new ArrayList(); - Row row = RowCreator.getRow(); - rows.add(row); - - when(trans.info()).thenReturn(target); - when(trans.start("Count Namespaces", Env.REMOTE)).thenReturn(tt); - when(session.execute(any(SimpleStatement.class))).thenReturn(results); - when(results.one()).thenReturn(row); - - assertEquals(0, NS.count(trans, session)); - } - - @Test - public void testV2() { - NS.v2_0_11.create(RowCreator.getRow()); - assertEquals(NS.v2_0_11.select(), "SELECT name, description, parent, type, scope FROM authz.ns "); - } + NS ns; + NSSplit nSSplit; + + @Before + public void setUp() { + ns = new NS("name", "description", "parent", 1, 1); + nSSplit = new NSSplit("string", 1); + } + + @Test + public void testToString() { + Assert.assertEquals("name", ns.toString()); + } + + @Test + public void testHashCode() { + Assert.assertEquals(3373707, ns.hashCode()); + } + + @Test + public void testEquals() { + Assert.assertEquals(true, ns.equals("name")); + Assert.assertEquals(false, ns.equals("name1")); + } + + @Test + public void testCompareTo() { + NS nsValid = new NS("name", "description", "parent", 1, 1); + Assert.assertEquals(0, ns.compareTo(nsValid)); + + NS nsInvalid = new NS("name1", "description", "parent", 1, 1); + Assert.assertEquals(-1, ns.compareTo(nsInvalid)); + } + + @Test + public void testDeriveParent() { + ns.deriveParent("d.ot.te.d"); + } + + @Test + public void testLoadWithoutNS() { + Trans trans = mock(Trans.class); + Session session = mock(Session.class); + Creator creator = mock(Creator.class); + LogTarget target = mock(LogTarget.class); + TimeTaken tt = mock(TimeTaken.class); + ResultSet results = mock(ResultSet.class); + ArrayList rows = new ArrayList(); + Row row = RowCreator.getRow(); + rows.add(row); + + when(trans.info()).thenReturn(target); + when(trans.start("Read Namespaces", Env.REMOTE)).thenReturn(tt); + when(trans.start("Load Namespaces", Env.SUB)).thenReturn(tt); + when(session.execute(any(SimpleStatement.class))).thenReturn(results); + when(results.iterator()).thenReturn(rows.iterator()); + when(creator.create(row)).thenReturn(ns); + + NS.load(trans, session, creator); + } + + @Test + public void testLoadOne() { + Trans trans = mock(Trans.class); + Session session = mock(Session.class); + Creator creator = mock(Creator.class); + LogTarget target = mock(LogTarget.class); + TimeTaken tt = mock(TimeTaken.class); + ResultSet results = mock(ResultSet.class); + ArrayList rows = new ArrayList(); + Row row = RowCreator.getRow(); + rows.add(row); + + when(trans.info()).thenReturn(target); + when(trans.start("Read Namespaces", Env.REMOTE)).thenReturn(tt); + when(trans.start("Load Namespaces", Env.SUB)).thenReturn(tt); + when(session.execute(any(SimpleStatement.class))).thenReturn(results); + when(results.iterator()).thenReturn(rows.iterator()); + when(creator.create(row)).thenReturn(ns); + + NS.loadOne(trans, session, creator, "text"); + } + + @Test + public void testCount() { + Trans trans = mock(Trans.class); + Session session = mock(Session.class); + LogTarget target = mock(LogTarget.class); + TimeTaken tt = mock(TimeTaken.class); + ResultSet results = mock(ResultSet.class); + ArrayList rows = new ArrayList(); + Row row = RowCreator.getRow(); + rows.add(row); + + when(trans.info()).thenReturn(target); + when(trans.start("Count Namespaces", Env.REMOTE)).thenReturn(tt); + when(session.execute(any(SimpleStatement.class))).thenReturn(results); + when(results.one()).thenReturn(row); + + assertEquals(0, NS.count(trans, session)); + } + + @Test + public void testV2() { + NS.v2_0_11.create(RowCreator.getRow()); + assertEquals(NS.v2_0_11.select(), "SELECT name, description, parent, type, scope FROM authz.ns "); + } }