* 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.
@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
}
@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);
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);
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);
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();
}
@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);