diff options
author | Dunietz, Irwin <id1681@att.com> | 2020-01-16 15:13:14 -0500 |
---|---|---|
committer | Takamune Cho <takamune.cho@att.com> | 2020-01-29 19:44:48 +0000 |
commit | b5fe8a69e90b950c07dc11af481eab7e9bab52c6 (patch) | |
tree | 3da81ce60554e65b93776b9aea647f3c6d8679ab /appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test | |
parent | 9b32cb60360a2a2973c621053510718de0072111 (diff) |
Change code in appc dispatcher for new LCMs in R6
Also introduce some minor improvements to robustness, efficiency, & formatting.
Issue-ID: APPC-1789
Signed-off-by: Dunietz, Irwin <id1681@att.com>
Change-Id: I82d970c2f7cde6c8dab1222af86ea70ce93b7e50
Diffstat (limited to 'appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test')
2 files changed, 23 insertions, 16 deletions
diff --git a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/MDSALStoreTest.java b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/MDSALStoreTest.java index 2229eff9d..973bf3d42 100644 --- a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/MDSALStoreTest.java +++ b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/MDSALStoreTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ================================================================================ @@ -11,15 +11,14 @@ * 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========================================================= */ @@ -48,9 +47,9 @@ import java.net.URL; * MDSALStore Tests */ @RunWith(PowerMockRunner.class) -@PrepareForTest({FrameworkUtil.class,BundleContext.class,ServiceReference.class, - BundleReference.class,Bundle.class,Filter.class,BundleListener.class,InvalidSyntaxException.class, - BundleException.class,FrameworkListener.class,ServiceRegistration.class,ServiceListener.class, +@PrepareForTest({FrameworkUtil.class, BundleContext.class, ServiceReference.class, + BundleReference.class, Bundle.class, Filter.class, BundleListener.class, InvalidSyntaxException.class, + BundleException.class, FrameworkListener.class, ServiceRegistration.class, ServiceListener.class, Version.class}) public class MDSALStoreTest { diff --git a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/impl/MDSALStoreImplTest.java b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/impl/MDSALStoreImplTest.java index fa1146237..dbb302e9e 100644 --- a/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/impl/MDSALStoreImplTest.java +++ b/appc-dg/appc-dg-shared/appc-dg-mdsal-store/appc-dg-mdsal-bundle/src/test/java/org/onap/appc/mdsal/impl/MDSALStoreImplTest.java @@ -3,6 +3,8 @@ * ONAP : APPC * ================================================================================ * Copyright (C) 2019 Ericsson + * ================================================================================ + * Modifications Copyright (C) 2019 AT&T Intellectual Property * ============================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,8 +59,8 @@ import java.net.URL; @PrepareForTest(FrameworkUtil.class) public class MDSALStoreImplTest { - private final BundleContext bundleContext= Mockito.mock(BundleContext.class); - private final Bundle bundleService=Mockito.mock(Bundle.class); + private final BundleContext bundleContext = Mockito.mock(BundleContext.class); + private final Bundle bundleService = Mockito.mock(Bundle.class); private MDSALStoreImpl mdsalStore; @Rule @@ -86,7 +88,8 @@ public class MDSALStoreImplTest { } @Test - public void testStoreYangModuleOnLeader() throws MDSALStoreException, APPCException, IllegalStateException, IOException { + public void testStoreYangModuleOnLeader() + throws MDSALStoreException, APPCException, IllegalStateException, IOException { RestClientInvoker mockInvoker = Mockito.mock(RestClientInvoker.class); Whitebox.setInternalState(mdsalStore, "client", mockInvoker); HttpResponse mockResponse = Mockito.mock(HttpResponse.class); @@ -100,7 +103,8 @@ public class MDSALStoreImplTest { Mockito.doReturn(mockStatusLine).when(mockResponse).getStatusLine(); Mockito.doReturn(200).when(mockStatusLine).getStatusCode(); HttpResponse mockLeaderResponse = Mockito.mock(HttpResponse.class); - Mockito.doReturn(mockLeaderResponse).when(mockInvoker).doGet(String.format(Constants.GET_NODE_STATUS_PATH_FORMAT, "NodeName-shard-default-config")); + Mockito.doReturn(mockLeaderResponse).when(mockInvoker) + .doGet(String.format(Constants.GET_NODE_STATUS_PATH_FORMAT, "NodeName-shard-default-config")); String httpLeaderString = "{\"value\":{\"Leader\":\"NodeName-shard-default-config\"}}"; InputStream isLeader = new ByteArrayInputStream(httpLeaderString.getBytes(Charset.defaultCharset())); HttpEntity mockLeaderEntity = Mockito.mock(HttpEntity.class); @@ -114,9 +118,10 @@ public class MDSALStoreImplTest { mdsalStore.storeYangModuleOnLeader("", ""); Mockito.verify(mockLogger).debug("Current node is a leader."); } - + @Test - public void testStoreYangModuleOnLeaderNotLeader() throws MDSALStoreException, APPCException, IllegalStateException, IOException { + public void testStoreYangModuleOnLeaderNotLeader() + throws MDSALStoreException, APPCException, IllegalStateException, IOException { RestClientInvoker mockInvoker = Mockito.mock(RestClientInvoker.class); Whitebox.setInternalState(mdsalStore, "client", mockInvoker); HttpResponse mockResponse = Mockito.mock(HttpResponse.class); @@ -130,8 +135,10 @@ public class MDSALStoreImplTest { Mockito.doReturn(mockStatusLine).when(mockResponse).getStatusLine(); Mockito.doReturn(200).when(mockStatusLine).getStatusCode(); HttpResponse mockLeaderResponse = Mockito.mock(HttpResponse.class); - Mockito.doReturn(mockLeaderResponse).when(mockInvoker).doGet(String.format(Constants.GET_NODE_STATUS_PATH_FORMAT, "NodeName-shard-default-config")); - String httpLeaderString = "{\"value\":{\"Leader\":\"OtherShardName\",\"PeerAddresses\":\"OtherShardName@adf:a\"}}"; + Mockito.doReturn(mockLeaderResponse).when(mockInvoker) + .doGet(String.format(Constants.GET_NODE_STATUS_PATH_FORMAT, "NodeName-shard-default-config")); + String httpLeaderString = + "{\"value\":{\"Leader\":\"OtherShardName\",\"PeerAddresses\":\"OtherShardName@adf:a\"}}"; InputStream isLeader = new ByteArrayInputStream(httpLeaderString.getBytes(Charset.defaultCharset())); HttpEntity mockLeaderEntity = Mockito.mock(HttpEntity.class); Mockito.doReturn(isLeader).when(mockLeaderEntity).getContent(); @@ -174,7 +181,8 @@ public class MDSALStoreImplTest { } @Test - public void testStoreJsonRestconfResponse() throws MDSALStoreException, APPCException, IllegalStateException, IOException { + public void testStoreJsonRestconfResponse() + throws MDSALStoreException, APPCException, IllegalStateException, IOException { RestClientInvoker mockInvoker = Mockito.mock(RestClientInvoker.class); Whitebox.setInternalState(mdsalStore, "client", mockInvoker); HttpResponse mockResponse = Mockito.mock(HttpResponse.class); |