diff options
Diffstat (limited to 'test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor')
6 files changed, 0 insertions, 415 deletions
diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfConfigurationCheckingTaskTest.java b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfConfigurationCheckingTaskTest.java deleted file mode 100644 index df5a13db2..000000000 --- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfConfigurationCheckingTaskTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/// * -// * ============LICENSE_START======================================================= -// * PNF-REGISTRATION-HANDLER -// * ================================================================================ -// * Copyright (C) 2018 NOKIA 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.pnfsimulator.netconfmonitor; -// -// import static org.mockito.ArgumentMatchers.any; -// import static org.mockito.Mockito.never; -// import static org.mockito.Mockito.verify; -// import static org.mockito.Mockito.when; -// -// import com.tailf.jnc.JNCException; -// import java.io.IOException; -// import org.junit.jupiter.api.BeforeEach; -// import org.junit.jupiter.api.Test; -// import org.mockito.Mock; -// import org.mockito.MockitoAnnotations; -// import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationCache; -// import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationReader; -// import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationWriter; -// -// class NetconfConfigurationCheckingTaskTest { -// -// private NetconfConfigurationCheckingTask checkingTask; -// -// @Mock -// private NetconfConfigurationReader reader; -// @Mock -// private NetconfConfigurationWriter writer; -// @Mock -// private NetconfConfigurationCache cache; -// -// @BeforeEach -// void setup() { -// MockitoAnnotations.initMocks(this); -// checkingTask = new NetconfConfigurationCheckingTask(reader, writer, cache); -// } -// -// @Test -// void run_should_update_configuration_when_changed() throws IOException, JNCException { -// String configuration = "newConfiguration"; -// when(reader.read()).thenReturn(configuration); -// when(cache.getConfiguration()).thenReturn("oldConfiguration"); -// -// checkingTask.run(); -// -// verify(reader).read(); -// verify(cache).getConfiguration(); -// verify(writer).writeToFile(configuration); -// verify(cache).update(configuration); -// } -// -// @Test -// void run_should_not_update_configuration_when_same() throws IOException, JNCException { -// String configuration = "configuration"; -// when(reader.read()).thenReturn(configuration); -// when(cache.getConfiguration()).thenReturn("configuration"); -// -// checkingTask.run(); -// -// verify(reader).read(); -// verify(cache).getConfiguration(); -// verify(writer, never()).writeToFile(configuration); -// verify(cache, never()).update(configuration); -// } -// -// @Test -// void run_should_not_take_any_action_when_failed_to_read_configuration() throws IOException, -/// JNCException { -// when(reader.read()).thenThrow(new IOException()); -// -// checkingTask.run(); -// -// verify(reader).read(); -// verify(cache, never()).getConfiguration(); -// verify(writer, never()).writeToFile(any()); -// verify(cache, never()).update(any()); -// } -// } diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceConfigurationTest.java b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceConfigurationTest.java deleted file mode 100644 index 3ff234b27..000000000 --- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceConfigurationTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/// * -// * ============LICENSE_START======================================================= -// * PNF-REGISTRATION-HANDLER -// * ================================================================================ -// * Copyright (C) 2018 NOKIA 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.pnfsimulator.netconfmonitor; -// -// import static org.junit.jupiter.api.Assertions.assertNotNull; -// import static org.mockito.ArgumentMatchers.any; -// import static org.mockito.Mockito.doReturn; -// import static org.mockito.Mockito.mock; -// import static org.mockito.Mockito.spy; -// import static org.mockito.Mockito.verify; -// -// import com.tailf.jnc.JNCException; -// import com.tailf.jnc.NetconfSession; -// import java.io.IOException; -// import org.junit.jupiter.api.BeforeEach; -// import org.junit.jupiter.api.Test; -// import org.mockito.Mock; -// -// class NetconfMonitorServiceConfigurationTest { -// -// private NetconfMonitorServiceConfiguration configuration; -// -// @Mock -// private NetconfSession netconfSession; -// -// @BeforeEach -// void setup() { -// netconfSession = mock(NetconfSession.class); -// configuration = spy(new NetconfMonitorServiceConfiguration()); -// } -// -// @Test -// void readNetconfConfiguration() throws IOException, JNCException { -// doReturn(netconfSession).when(configuration).createNetconfSession(any()); -// -// assertNotNull(configuration.configurationReader()); -// verify(configuration).createNetconfSession(any()); -// } -// -// @Test -// void configurationCacheIsNotNull() { -// assertNotNull(configuration.configurationCache()); -// } -// -// @Test -// void netconfConfigurationWriterIsNotNull() { -// assertNotNull(configuration.netconfConfigurationWriter()); -// } -// -// @Test -// void timerIsNotNull() { -// assertNotNull(configuration.timer()); -// } -// } diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceTest.java b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceTest.java deleted file mode 100644 index f8690c5ce..000000000 --- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/NetconfMonitorServiceTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/// * -// * ============LICENSE_START======================================================= -// * PNF-REGISTRATION-HANDLER -// * ================================================================================ -// * Copyright (C) 2018 NOKIA 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.pnfsimulator.netconfmonitor; -// -// import static org.mockito.ArgumentMatchers.anyString; -// import static org.mockito.Mockito.any; -// import static org.mockito.Mockito.anyLong; -// import static org.mockito.Mockito.doNothing; -// import static org.mockito.Mockito.times; -// import static org.mockito.Mockito.verify; -// import static org.mockito.Mockito.when; -// -// import com.tailf.jnc.JNCException; -// import java.io.IOException; -// import java.util.Timer; -// import org.junit.jupiter.api.BeforeEach; -// import org.junit.jupiter.api.Test; -// import org.mockito.Mock; -// import org.mockito.MockitoAnnotations; -// import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationCache; -// import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationReader; -// import org.onap.pnfsimulator.netconfmonitor.netconf.NetconfConfigurationWriter; -// -// class NetconfMonitorServiceTest { -// -// private NetconfMonitorService service; -// -// @Mock -// private Timer timer; -// @Mock -// private NetconfConfigurationReader reader; -// @Mock -// private NetconfConfigurationWriter writer; -// @Mock -// private NetconfConfigurationCache cache; -// -// @BeforeEach -// void setup() { -// MockitoAnnotations.initMocks(this); -// service = new NetconfMonitorService(timer, reader, writer, cache); -// } -// -// @Test -// void startNetconfService() throws IOException, JNCException { -// when(reader.read()).thenReturn("message"); -// doNothing().when(writer).writeToFile(anyString()); -// doNothing().when(cache).update(anyString()); -// -// service.start(); -// -// verify(cache, times(1)).update(anyString()); -// verify(writer, times(1)).writeToFile(anyString()); -// verify(timer, times(1)).scheduleAtFixedRate(any(), anyLong(), anyLong()); -// } -// } diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationCacheTest.java b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationCacheTest.java deleted file mode 100644 index 56f62ac50..000000000 --- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationCacheTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA 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.pnfsimulator.netconfmonitor.netconf; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.Test; - -public class NetconfConfigurationCacheTest { - - private static final String CONFIGURATION = "sampleConfiguration"; - - @Test - void changeConfigurationAfterUpdate() { - NetconfConfigurationCache configurationCache = new NetconfConfigurationCache(); - configurationCache.update(CONFIGURATION); - - assertEquals(CONFIGURATION, configurationCache.getConfiguration()); - } -}
\ No newline at end of file diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationReaderTest.java b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationReaderTest.java deleted file mode 100644 index 65b2bc32e..000000000 --- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationReaderTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA 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.pnfsimulator.netconfmonitor.netconf; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.tailf.jnc.Element; -import com.tailf.jnc.JNCException; -import com.tailf.jnc.NetconfSession; -import com.tailf.jnc.NodeSet; -import java.io.IOException; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -class NetconfConfigurationReaderTest { - - private static final String NETCONF_MODEL_PATH = ""; - private static final String EXPECTED_STRING_XML = "<?xml version=\"1.0\"?>"; - private NetconfConfigurationReader reader; - - @Mock - private NetconfSession netconfSession; - @Mock - private NodeSet nodeSet; - @Mock - private Element element; - - @BeforeEach - void setup() { - MockitoAnnotations.initMocks(this); - reader = new NetconfConfigurationReader(netconfSession, NETCONF_MODEL_PATH); - } - - @Test - void properlyReadXML() throws IOException, JNCException { - when(netconfSession.getConfig(anyString())).thenReturn(nodeSet); - when(nodeSet.first()).thenReturn(element); - when(element.toXMLString()).thenReturn(EXPECTED_STRING_XML); - - String result = reader.read(); - - verify(netconfSession).getConfig(anyString()); - verify(nodeSet).first(); - verify(element).toXMLString(); - assertEquals(EXPECTED_STRING_XML, result); - } -}
\ No newline at end of file diff --git a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationWriterTest.java b/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationWriterTest.java deleted file mode 100644 index 2baee21b7..000000000 --- a/test/mocks/mass-pnf-sim/pnf-sim-lightweight/src/test/java/org/onap/pnfsimulator/netconfmonitor/netconf/NetconfConfigurationWriterTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA 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.pnfsimulator.netconfmonitor.netconf; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import org.apache.commons.io.FileUtils; -import org.junit.Rule; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport; -import org.junit.rules.TemporaryFolder; - -@EnableRuleMigrationSupport -class NetconfConfigurationWriterTest { - - private static final String TEST_CONFIGURATION = "test-configuration"; - - @Rule - public TemporaryFolder temporaryFolder = new TemporaryFolder(); - - @Test - void writeToFile_should_write_sample_config_when_directory_exists() throws IOException { - File file = temporaryFolder.newFolder("temp"); - NetconfConfigurationWriter configurationWriter = new NetconfConfigurationWriter(file.getPath()); - - configurationWriter.writeToFile(TEST_CONFIGURATION); - - File[] files = file.listFiles(); - assertEquals(1, files.length); - - String content = FileUtils.readFileToString(files[0], "UTF-8"); - assertEquals(TEST_CONFIGURATION, content); - } - - @Test - void writeToFile_should_not_write_config_when_directory_doesnt_exist() { - String logFolderPath = "/not/existing/logs"; - NetconfConfigurationWriter configurationWriter = new NetconfConfigurationWriter(logFolderPath); - - configurationWriter.writeToFile(TEST_CONFIGURATION); - - assertFalse(Files.exists(Paths.get(logFolderPath))); - } -}
\ No newline at end of file |