diff options
Diffstat (limited to 'plugins/reception-plugins/src/test')
-rw-r--r-- | plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java (renamed from plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandler.java) | 31 | ||||
-rw-r--r-- | plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java (renamed from plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandlerConfigurationParameterGroup.java) | 4 |
2 files changed, 18 insertions, 17 deletions
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandler.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java index fc2a2b6a..20922a1b 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandler.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Intel. All rights reserved. + * Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.handling.sdc; +package org.onap.policy.distribution.reception.handling.file; import static org.junit.Assert.fail; @@ -92,16 +93,16 @@ public class TestFileSystemReceptionHandler { @Test public final void testInit() throws IOException { final FileSystemReceptionHandler sypHandler = Mockito.spy(fileSystemHandler); - Mockito.doNothing().when(sypHandler).main(Mockito.isA(String.class)); + Mockito.doNothing().when(sypHandler).initFileWatcher(Mockito.isA(String.class)); sypHandler.initializeReception(pssdConfigParameters.getName()); - Mockito.verify(sypHandler, Mockito.times(1)).main(Mockito.isA(String.class)); + Mockito.verify(sypHandler, Mockito.times(1)).initFileWatcher(Mockito.isA(String.class)); } @Test public final void testDestroy() throws IOException { try { final FileSystemReceptionHandler sypHandler = Mockito.spy(fileSystemHandler); - Mockito.doNothing().when(sypHandler).main(Mockito.isA(String.class)); + Mockito.doNothing().when(sypHandler).initFileWatcher(Mockito.isA(String.class)); sypHandler.initializeReception(pssdConfigParameters.getName()); sypHandler.destroy(); } catch (final Exception exp) { @@ -120,11 +121,12 @@ public class TestFileSystemReceptionHandler { public boolean processed = false; } - Processed cond = new Processed(); + final Processed cond = new Processed(); final FileSystemReceptionHandler sypHandler = Mockito.spy(fileSystemHandler); Mockito.doAnswer(new Answer<Object>() { - public Object answer(InvocationOnMock invocation) { + @Override + public Object answer(final InvocationOnMock invocation) { synchronized (lock) { cond.processed = true; lock.notifyAll(); @@ -133,18 +135,18 @@ public class TestFileSystemReceptionHandler { } }).when(sypHandler).createPolicyInputAndCallHandler(Mockito.isA(String.class)); - Thread th = new Thread(() -> { + final Thread th = new Thread(() -> { try { - sypHandler.main(watchPath); - } catch (IOException ex) { + sypHandler.initFileWatcher(watchPath); + } catch (final IOException ex) { LOGGER.error(ex); } }); th.start(); try { - //wait until internal watch service started or counter reached - AtomicInteger counter = new AtomicInteger(); + // wait until internal watch service started or counter reached + final AtomicInteger counter = new AtomicInteger(); counter.set(0); synchronized (lock) { while (!sypHandler.isRunning() && counter.getAndIncrement() < 10) { @@ -152,8 +154,8 @@ public class TestFileSystemReceptionHandler { } } Files.copy(Paths.get("src/test/resources/hpaPolicyHugePage.csar"), - Paths.get(watchPath + File.separator + "hpaPolicyHugePage.csar")); - //wait until mock method triggered or counter reached + Paths.get(watchPath + File.separator + "hpaPolicyHugePage.csar")); + // wait until mock method triggered or counter reached counter.set(0); synchronized (lock) { while (!cond.processed && counter.getAndIncrement() < 10) { @@ -166,8 +168,7 @@ public class TestFileSystemReceptionHandler { } catch (final InterruptedException ex) { LOGGER.error(ex); } - Mockito.verify(sypHandler, Mockito.times(1)) - .createPolicyInputAndCallHandler(Mockito.isA(String.class)); + Mockito.verify(sypHandler, Mockito.times(1)).createPolicyInputAndCallHandler(Mockito.isA(String.class)); } } diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandlerConfigurationParameterGroup.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java index 3039560a..92d9443e 100644 --- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestFileSystemReceptionHandlerConfigurationParameterGroup.java +++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Intel. All rights reserved. + * Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.distribution.reception.handling.sdc; +package org.onap.policy.distribution.reception.handling.file; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -34,7 +35,6 @@ import java.io.IOException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; - import org.onap.policy.common.parameters.GroupValidationResult; /** |