--- /dev/null
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+package org.onap.aaf.auth.locate.service;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import static org.mockito.Matchers.any;\r
+import static org.mockito.Mockito.when;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.Mock;\r
+import org.mockito.MockitoAnnotations;\r
+import org.onap.aaf.auth.dao.cass.LocateDAO;\r
+import org.onap.aaf.auth.dao.cass.LocateDAO.Data;\r
+import org.onap.aaf.auth.env.AuthzTrans;\r
+import org.onap.aaf.auth.layer.Result;\r
+import org.onap.aaf.auth.locate.mapper.Mapper;\r
+import org.onap.aaf.misc.env.APIException;\r
+\r
+import locate.v1_0.MgmtEndpoint;\r
+import locate.v1_0.MgmtEndpoints;\r
+\r
+public class JU_LocateServiceImplTest {\r
+\r
+ @Mock\r
+ private AuthzTrans trans;\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
+ LocateServiceImpl locateServiceImpl = new LocateServiceImpl(trans, locateDAO, mapper);\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<MgmtEndpoint>();\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