--- /dev/null
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+package org.onap.aaf.auth.gui;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.onap.aaf.misc.xgen.Cache;
+import org.onap.aaf.misc.xgen.html.HTMLGen;
+
+public class JU_FormTest {
+
+ @Mock
+ private Cache<HTMLGen> cache;
+
+ @Mock
+ private HTMLGen hgen;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ }
+
+ @Test
+ public void test() throws Exception {
+ when(hgen.incr("p", "class=preamble")).thenReturn(hgen);
+ when(hgen.text("preamable")).thenReturn(hgen);
+ when(hgen.tagOnly("input", "type=submit", "value=Submit")).thenReturn(hgen);
+ when(hgen.tagOnly("input", "type=reset", "value=Reset")).thenReturn(hgen);
+
+ Form form = new Form(false, new BreadCrumbs(null));
+
+ assertThat(form.idattrs(), equalTo(new String[] { "breadcrumbs" }));
+
+ assertThat(form.preamble("preamable"), equalTo(form));
+
+ form.code(cache, hgen);
+ }
+
+}
--- /dev/null
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+package org.onap.aaf.auth.gui;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.onap.aaf.auth.gui.Table.Data;
+import org.onap.aaf.misc.env.APIException;
+import org.onap.aaf.misc.env.TransStore;
+import org.onap.aaf.misc.xgen.Cache;
+import org.onap.aaf.misc.xgen.Code;
+import org.onap.aaf.misc.xgen.html.HTMLGen;
+
+public class JU_TableTest {
+
+ @Mock
+ private TransStore trans;
+ private Code<HTMLGen> other;
+ @Mock
+ private Data data;
+ @Mock
+ private Cache cache;
+ @Mock
+ private HTMLGen hgen;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ }
+
+ @Test
+ public void test() throws APIException, IOException {
+ when(hgen.leaf("caption", "class=title")).thenReturn(hgen);
+ when(hgen.text("title")).thenReturn(hgen);
+ when(data.headers()).thenReturn(new String[0]);
+
+ Table table = new Table("title", trans, data, other, "name", "attr1", "attr1");
+ Table.Cells cells = new Table.Cells(new ArrayList(), "");
+
+ table.code(cache, hgen);
+
+ verify(hgen).end();
+ }
+
+}
--- /dev/null
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+
+package org.onap.aaf.auth.gui.table;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.onap.aaf.auth.gui.table.CheckBoxCell.ALIGN;
+import org.onap.aaf.misc.xgen.html.HTMLGen;
+
+public class JU_UICellTest {
+ @Mock
+ private HTMLGen hgen;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ }
+
+ @Test
+ public void testButtonCell() {
+ String[] attrs = { "type=button", "value=null", "attribute1", "attribute2" };
+ ButtonCell cell = new ButtonCell(null, "attribute1", "attribute2");
+
+ when(hgen.incr("input", true, attrs)).thenReturn(hgen);
+
+ cell.write(hgen);
+
+ AbsCell.Null.write(hgen);
+
+ assertThat(AbsCell.Null.attrs(), equalTo(new String[0]));
+
+ assertThat(cell.attrs(), equalTo(AbsCell.CENTER));
+
+ verify(hgen).end();
+ }
+
+ @Test
+ public void testCheckBoxCellWithoutAlign() {
+ String[] attrs = { "type=checkbox", "name=name", "value=attribute1", "attribute2" };
+ CheckBoxCell cell = new CheckBoxCell("name", "attribute1", "attribute2");
+
+ cell.write(hgen);
+
+ assertThat(cell.attrs(), equalTo(AbsCell.CENTER));
+
+ verify(hgen).tagOnly("input", attrs);
+ }
+
+ @Test
+ public void testCheckBoxCellWithLeftAlign() {
+ String[] attrs = { "type=checkbox", "name=name", "value=attribute1", "attribute2" };
+ CheckBoxCell cell = new CheckBoxCell("name", ALIGN.left, "attribute1", "attribute2");
+
+ cell.write(hgen);
+
+ assertThat(cell.attrs(), equalTo(AbsCell.LEFT));
+
+ verify(hgen).tagOnly("input", attrs);
+ }
+
+ @Test
+ public void testCheckBoxCellWithRightAlign() {
+ String[] attrs = { "type=checkbox", "name=name", "value=attribute1", "attribute2" };
+ CheckBoxCell cell = new CheckBoxCell("name", ALIGN.right, "attribute1", "attribute2");
+
+ cell.write(hgen);
+
+ assertThat(cell.attrs(), equalTo(AbsCell.RIGHT));
+
+ verify(hgen).tagOnly("input", attrs);
+ }
+
+ @Test
+ public void testRadioCell() {
+ String[] attrs = { "type=radio", "name=name", "class=attribute1", "value=attribute2" };
+ RadioCell cell = new RadioCell("name", "attribute1", "attribute2");
+
+ cell.write(hgen);
+
+ assertThat(cell.attrs(), equalTo(AbsCell.CENTER));
+
+ verify(hgen).tagOnly("input", attrs);
+ }
+
+ @Test
+ public void testRefCellWithNewWindow() {
+ String[] attrs = { "href=attribute1", "attribute2", null };
+ RefCell cell = new RefCell("name", "attribute1", true, "attribute2");
+
+ when(hgen.leaf(HTMLGen.A, attrs)).thenReturn(hgen);
+
+ cell.write(hgen);
+
+ assertThat(cell.attrs(), equalTo(new String[0]));
+ }
+
+ @Test
+ public void testRefCellWithoutNewWindow() {
+ String[] attrs = { "href=attribute1", "attribute2" };
+ RefCell cell = new RefCell("name", "attribute1", false, "attribute2");
+
+ when(hgen.leaf(HTMLGen.A, attrs)).thenReturn(hgen);
+
+ cell.write(hgen);
+
+ assertThat(cell.attrs(), equalTo(new String[0]));
+
+ }
+
+ @Test
+ public void testTextAndRefCell() {
+ String[] attrs = { "href=href", "attribute1", null };
+ String[] attributes = { "attribute1" };
+ TextAndRefCell cell = new TextAndRefCell("text", "name", "href", true, attributes);
+
+ when(hgen.leaf(HTMLGen.A, attrs)).thenReturn(hgen);
+
+ cell.write(hgen);
+
+ verify(hgen).text("text");
+ }
+
+ @Test
+ public void testTextCell() {
+ String[] attrs = { "href" };
+ TextCell cell = new TextCell("name", "href");
+
+ cell.write(hgen);
+
+ assertThat(cell.attrs(), equalTo(attrs));
+
+ verify(hgen).text("name");
+ }
+
+ @Test
+ public void testTextInputCell() {
+ String[] attrs = { "href" };
+ TextInputCell cell = new TextInputCell("name", "textClass", "value");
+
+ cell.write(hgen);
+
+ assertThat(cell.attrs(), equalTo(new String[0]));
+ }
+}
* ============LICENSE_END====================================================\r
*\r
*/\r
-\r
package org.onap.aaf.auth.locate;\r
\r
import static org.junit.Assert.assertEquals;\r
import org.onap.aaf.misc.env.LogTarget;\r
\r
public class JU_BasicAuthCodeTest {\r
+ @Mock\r
+ AAFAuthn authn;\r
\r
- @Mock\r
- AAFAuthn authn;\r
-\r
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)\r
- AuthzTrans trans;\r
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)\r
+ AuthzTrans trans;\r
\r
- @Mock\r
- HttpServletRequest req;\r
+ @Mock\r
+ HttpServletRequest req;\r
\r
- @Mock\r
- HttpServletResponse resp;\r
+ @Mock\r
+ HttpServletResponse resp;\r
\r
- @Mock\r
- LogTarget error;\r
+ @Mock\r
+ LogTarget error;\r
\r
- @Mock\r
- LocateFacade facade;\r
+ @Mock\r
+ LocateFacade facade;\r
\r
- @Mock\r
- BasicPrincipal basicPrincipal;\r
- @Mock\r
- X509Principal x509Principal;\r
+ @Mock\r
+ BasicPrincipal basicPrincipal;\r
+ @Mock\r
+ X509Principal x509Principal;\r
\r
- @Before\r
- public void setUp() throws Exception {\r
- initMocks(this);\r
- }\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ initMocks(this);\r
+ }\r
\r
- @Test\r
- public void testWithNullUserPrincipal() throws Exception {\r
- BasicAuthCode basicAuthCode = new BasicAuthCode(authn, facade);\r
- LocateCode locateCode = basicAuthCode.clone(facade, false);\r
+ @Test\r
+ public void testWithNullUserPrincipal() throws Exception {\r
+ BasicAuthCode basicAuthCode = new BasicAuthCode(authn, facade);\r
+ LocateCode locateCode = basicAuthCode.clone(facade, false);\r
\r
- assertEquals(locateCode.desc(), basicAuthCode.desc());\r
+ assertEquals(locateCode.desc(), basicAuthCode.desc());\r
\r
- when(trans.getUserPrincipal()).thenReturn(null);\r
- when(trans.error()).thenReturn(error);\r
+ when(trans.getUserPrincipal()).thenReturn(null);\r
+ when(trans.error()).thenReturn(error);\r
\r
- basicAuthCode.handle(trans, req, resp);\r
- }\r
+ basicAuthCode.handle(trans, req, resp);\r
+ }\r
\r
- @Test\r
- public void testWithBasicUserPrincipal() throws Exception {\r
- BasicAuthCode basicAuthCode = new BasicAuthCode(authn, facade);\r
- LocateCode locateCode = basicAuthCode.clone(facade, false);\r
+ @Test\r
+ public void testWithBasicUserPrincipal() throws Exception {\r
+ BasicAuthCode basicAuthCode = new BasicAuthCode(authn, facade);\r
+ LocateCode locateCode = basicAuthCode.clone(facade, false);\r
\r
- assertEquals(locateCode.desc(), basicAuthCode.desc());\r
+ assertEquals(locateCode.desc(), basicAuthCode.desc());\r
\r
- when(trans.getUserPrincipal()).thenReturn(basicPrincipal);\r
+ when(trans.getUserPrincipal()).thenReturn(basicPrincipal);\r
\r
- basicAuthCode.handle(trans, req, resp);\r
+ basicAuthCode.handle(trans, req, resp);\r
\r
- verify(resp).setStatus(HttpStatus.OK_200);\r
- }\r
+ verify(resp).setStatus(HttpStatus.OK_200);\r
+ }\r
\r
- @Test\r
- public void testWithX509UserPrincipal() throws Exception {\r
- BasicAuthCode basicAuthCode = new BasicAuthCode(authn, facade);\r
- LocateCode locateCode = basicAuthCode.clone(facade, false);\r
+ @Test\r
+ public void testWithX509UserPrincipal() throws Exception {\r
+ BasicAuthCode basicAuthCode = new BasicAuthCode(authn, facade);\r
+ LocateCode locateCode = basicAuthCode.clone(facade, false);\r
\r
- assertEquals(locateCode.desc(), basicAuthCode.desc());\r
+ assertEquals(locateCode.desc(), basicAuthCode.desc());\r
\r
- when(trans.getUserPrincipal()).thenReturn(x509Principal);\r
- when(req.getHeader("Authorization")).thenReturn("Basic 76//76");\r
+ when(trans.getUserPrincipal()).thenReturn(x509Principal);\r
+ when(req.getHeader("Authorization")).thenReturn("Basic 76//76");\r
\r
- basicAuthCode.handle(trans, req, resp);\r
+ basicAuthCode.handle(trans, req, resp);\r
\r
- verify(resp).setStatus(HttpStatus.FORBIDDEN_403);\r
- }\r
+ verify(resp).setStatus(HttpStatus.FORBIDDEN_403);\r
+ }\r
\r
}\r
--- /dev/null
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+package org.onap.aaf.auth.locate.api;
+
+import static org.junit.Assert.fail;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.onap.aaf.auth.locate.AAF_Locate;
+import org.onap.aaf.auth.locate.facade.LocateFacade;
+
+public class JU_API_AAFTest {
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private AAF_Locate gwAPI;
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private LocateFacade facade;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ }
+
+ @Test
+ public void testAPI_AAFAccess() throws Exception {
+ try {
+ API_AAFAccess.init(gwAPI, facade);
+ } catch (Exception e) {
+ fail("There should be no exception as Mocks are used");
+ }
+ }
+
+ @Test
+ public void testAPI_Find() throws Exception {
+ try {
+ API_Find.init(gwAPI, facade);
+ } catch (Exception e) {
+ fail("There should be no exception as Mocks are used");
+ }
+ }
+
+ @Test
+ public void testAPI_API() throws Exception {
+ try {
+ API_Api.init(gwAPI, facade);
+ } catch (Exception e) {
+ fail("There should be no exception as Mocks are used");
+ }
+ }
+}
* ============LICENSE_END====================================================\r
*\r
*/\r
-\r
package org.onap.aaf.auth.locate.mapper;\r
\r
import static org.junit.Assert.assertEquals;\r
\r
public class JU_Mapper_1_0Test {\r
\r
- @Before\r
- public void setUp() throws Exception {\r
+ @Before\r
+ public void setUp() throws Exception {\r
\r
- }\r
+ }\r
\r
- @Test\r
- public void testGetClasses() {\r
- Mapper_1_1 mapper = new Mapper_1_1();\r
- assertEquals(InRequest.class, mapper.getClass(API.IN_REQ));\r
- assertEquals(Out.class, mapper.getClass(API.OUT));\r
- assertEquals(Error.class, mapper.getClass(API.ERROR));\r
- assertEquals(Void.class, mapper.getClass(API.VOID));\r
- assertEquals(Endpoints.class, mapper.getClass(API.ENDPOINTS));\r
- assertEquals(MgmtEndpoints.class, mapper.getClass(API.MGMT_ENDPOINTS));\r
- }\r
+ @Test\r
+ public void testGetClasses() {\r
+ Mapper_1_1 mapper = new Mapper_1_1();\r
+ assertEquals(InRequest.class, mapper.getClass(API.IN_REQ));\r
+ assertEquals(Out.class, mapper.getClass(API.OUT));\r
+ assertEquals(Error.class, mapper.getClass(API.ERROR));\r
+ assertEquals(Void.class, mapper.getClass(API.VOID));\r
+ assertEquals(Endpoints.class, mapper.getClass(API.ENDPOINTS));\r
+ assertEquals(MgmtEndpoints.class, mapper.getClass(API.MGMT_ENDPOINTS));\r
+ }\r
\r
- @Test\r
- public void testNewInstance() {\r
- Mapper_1_1 mapper = new Mapper_1_1();\r
- assertTrue(mapper.newInstance(API.IN_REQ) instanceof InRequest);\r
- assertTrue(mapper.newInstance(API.OUT) instanceof Out);\r
- assertTrue(mapper.newInstance(API.ERROR) instanceof Error);\r
- assertTrue(mapper.newInstance(API.ENDPOINTS) instanceof Endpoints);\r
- assertTrue(mapper.newInstance(API.MGMT_ENDPOINTS) instanceof MgmtEndpoints);\r
- assertEquals(null, mapper.newInstance(API.VOID));\r
- }\r
+ @Test\r
+ public void testNewInstance() {\r
+ Mapper_1_1 mapper = new Mapper_1_1();\r
+ assertTrue(mapper.newInstance(API.IN_REQ) instanceof InRequest);\r
+ assertTrue(mapper.newInstance(API.OUT) instanceof Out);\r
+ assertTrue(mapper.newInstance(API.ERROR) instanceof Error);\r
+ assertTrue(mapper.newInstance(API.ENDPOINTS) instanceof Endpoints);\r
+ assertTrue(mapper.newInstance(API.MGMT_ENDPOINTS) instanceof MgmtEndpoints);\r
+ assertEquals(null, mapper.newInstance(API.VOID));\r
+ }\r
\r
}\r
* ============LICENSE_END====================================================\r
*\r
*/\r
-\r
package org.onap.aaf.auth.locate.service;\r
\r
import static org.junit.Assert.assertEquals;\r
\r
public class JU_LocateServiceImplTest {\r
\r
- // Extend, because I don't want a "setter" in the original. Compromised with a protected...\r
- private final class LocateServiceImplExtension extends LocateServiceImpl {\r
- private LocateServiceImplExtension(AuthzTrans trans, AAF_Locate locate, Mapper mapper) throws APIException {\r
- super(trans, locate, mapper);\r
- }\r
- public void set(LocateDAO ld) {\r
- locateDAO=ld;\r
- }\r
- }\r
-\r
- @Mock\r
- private AuthzTrans trans;\r
- @Mock\r
- private AAF_Locate aaf_locate;\r
- @Mock\r
- private LocateDAO locateDAO;\r
- @Mock\r
- private Mapper mapper;\r
- @Mock\r
- private Result<List<Data>> result;\r
- @Mock\r
- private Result endPointResult;\r
- @Mock\r
- private MgmtEndpoints meps;\r
- @Mock\r
- private MgmtEndpoint mgmtEndPoint;\r
-\r
- @Before\r
- public void setup() {\r
- MockitoAnnotations.initMocks(this);\r
- }\r
-\r
- @Test\r
- public void test() throws APIException {\r
- LocateServiceImplExtension locateServiceImpl = new LocateServiceImplExtension(trans, aaf_locate, mapper);\r
- locateServiceImpl.set(locateDAO);\r
-\r
- assertEquals(mapper, locateServiceImpl.mapper());\r
-\r
- when(locateDAO.readByName(trans, "http")).thenReturn(result);\r
- when(mapper.endpoints(result, "1.0", "other")).thenReturn(endPointResult);\r
-\r
- Result output = locateServiceImpl.getEndPoints(trans, "http", "1.0", "other");\r
-\r
- assertEquals(endPointResult, output);\r
-\r
- List<MgmtEndpoint> mgmtEndPoints = new ArrayList<>();\r
- mgmtEndPoints.add(mgmtEndPoint);\r
-\r
- when(mgmtEndPoint.getName()).thenReturn("http.Endpoint1");\r
- when(mgmtEndPoint.getHostname()).thenReturn("HOST1");\r
- when(mgmtEndPoint.getPort()).thenReturn(9090);\r
- when(mgmtEndPoint.getProtocol()).thenReturn("HTTP");\r
-\r
- when(meps.getMgmtEndpoint()).thenReturn(mgmtEndPoints);\r
- output = locateServiceImpl.putMgmtEndPoints(trans, meps);\r
-\r
- assertEquals(output.toString(), Result.ok().toString());\r
-\r
- when(trans.fish(any())).thenReturn(true);\r
- Data data = new LocateDAO.Data();\r
- when(mapper.locateData(mgmtEndPoint)).thenReturn(data);\r
- output = locateServiceImpl.removeMgmtEndPoints(trans, meps);\r
-\r
- assertEquals(output.toString(), Result.ok().toString());\r
- }\r
+ // Extend, because I don't want a "setter" in the original. Compromised with a protected...\r
+ private final class LocateServiceImplExtension extends LocateServiceImpl {\r
+ private LocateServiceImplExtension(AuthzTrans trans, AAF_Locate locate, Mapper mapper) throws APIException {\r
+ super(trans, locate, mapper);\r
+ }\r
+ public void set(LocateDAO ld) {\r
+ locateDAO=ld;\r
+ }\r
+ }\r
+\r
+ @Mock\r
+ private AuthzTrans trans;\r
+ @Mock\r
+ private AAF_Locate aaf_locate;\r
+ @Mock\r
+ private LocateDAO locateDAO;\r
+ @Mock\r
+ private Mapper mapper;\r
+ @Mock\r
+ private Result<List<Data>> result;\r
+ @Mock\r
+ private Result endPointResult;\r
+ @Mock\r
+ private MgmtEndpoints meps;\r
+ @Mock\r
+ private MgmtEndpoint mgmtEndPoint;\r
+\r
+ @Before\r
+ public void setup() {\r
+ MockitoAnnotations.initMocks(this);\r
+ }\r
+\r
+ @Test\r
+ public void test() throws APIException {\r
+ LocateServiceImplExtension locateServiceImpl = new LocateServiceImplExtension(trans, aaf_locate, mapper);\r
+ locateServiceImpl.set(locateDAO);\r
+\r
+ assertEquals(mapper, locateServiceImpl.mapper());\r
+\r
+ when(locateDAO.readByName(trans, "http")).thenReturn(result);\r
+ when(mapper.endpoints(result, "1.0", "other")).thenReturn(endPointResult);\r
+\r
+ Result output = locateServiceImpl.getEndPoints(trans, "http", "1.0", "other");\r
+\r
+ assertEquals(endPointResult, output);\r
+\r
+ List<MgmtEndpoint> mgmtEndPoints = new ArrayList<>();\r
+ mgmtEndPoints.add(mgmtEndPoint);\r
+\r
+ when(mgmtEndPoint.getName()).thenReturn("http.Endpoint1");\r
+ when(mgmtEndPoint.getHostname()).thenReturn("HOST1");\r
+ when(mgmtEndPoint.getPort()).thenReturn(9090);\r
+ when(mgmtEndPoint.getProtocol()).thenReturn("HTTP");\r
+\r
+ when(meps.getMgmtEndpoint()).thenReturn(mgmtEndPoints);\r
+ output = locateServiceImpl.putMgmtEndPoints(trans, meps);\r
+\r
+ assertEquals(output.toString(), Result.ok().toString());\r
+\r
+ when(trans.fish(any())).thenReturn(true);\r
+ Data data = new LocateDAO.Data();\r
+ when(mapper.locateData(mgmtEndPoint)).thenReturn(data);\r
+ output = locateServiceImpl.removeMgmtEndPoints(trans, meps);\r
+\r
+ assertEquals(output.toString(), Result.ok().toString());\r
+ }\r
\r
}\r
* ============LICENSE_END====================================================\r
*\r
*/\r
-\r
package org.onap.aaf.auth.locate.validation;\r
\r
import static org.junit.Assert.assertEquals;\r