diff options
Diffstat (limited to 'framework/src/test/java/org/onap/cli/fw/store/OnapCommandExecutionStoreTest.java')
-rw-r--r-- | framework/src/test/java/org/onap/cli/fw/store/OnapCommandExecutionStoreTest.java | 69 |
1 files changed, 45 insertions, 24 deletions
diff --git a/framework/src/test/java/org/onap/cli/fw/store/OnapCommandExecutionStoreTest.java b/framework/src/test/java/org/onap/cli/fw/store/OnapCommandExecutionStoreTest.java index 6b69f0b0..639f6239 100644 --- a/framework/src/test/java/org/onap/cli/fw/store/OnapCommandExecutionStoreTest.java +++ b/framework/src/test/java/org/onap/cli/fw/store/OnapCommandExecutionStoreTest.java @@ -16,8 +16,10 @@ package org.onap.cli.fw.store; +import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; +import org.onap.cli.fw.cmd.execution.OnapCommandExceutionListCommandTest; import org.onap.cli.fw.error.OnapCommandExecutionFailed; import java.io.File; @@ -28,58 +30,77 @@ import static org.junit.Assert.*; public class OnapCommandExecutionStoreTest { OnapCommandExecutionStore executionStore; + @Before public void setUp() throws Exception { - executionStore=OnapCommandExecutionStore.getStore(); + executionStore = OnapCommandExecutionStore.getStore(); } + @Test - public void storeExectutionStartTest(){ - assertNotNull(executionStore.storeExectutionStart("requestId","product","service","cmd","profile","input")); + public void storeExectutionStartTest() { + assertNotNull(executionStore.storeExectutionStart("requestId", "product", "service", "cmd", "profile", "input")); } + @Test public void listExecutionsTest() throws OnapCommandExecutionFailed { - Map<String,String> search=new HashMap<>(); - search.put("startTime","12"); - search.put("endTime","12"); - search.put("execution-id","abc"); - search.put("request-id","abc"); + Map<String, String> search = new HashMap<>(); + search.put("startTime", "12"); + search.put("endTime", "12"); + search.put("execution-id", "abc"); + search.put("request-id", "abc"); assertNotNull(executionStore.listExecutions(search)); } + @Test - public void storeExectutionEndTest(){ - OnapCommandExecutionStore.ExecutionStoreContext store=new OnapCommandExecutionStore.ExecutionStoreContext(); + public void storeExectutionEndTest() { + OnapCommandExecutionStore.ExecutionStoreContext store = new OnapCommandExecutionStore.ExecutionStoreContext(); store.setExecutionId("abc"); store.setRequestId("abc"); store.setStorePath("abc"); - executionStore.storeExectutionEnd(store,"abc","abc","abc",true); - assertTrue(new File(System.getProperty("user.dir")+File.separator+"abc").exists()); + executionStore.storeExectutionEnd(store, "abc", "abc", "abc", true); + assertTrue(new File(System.getProperty("user.dir") + File.separator + "abc").exists()); } + @Test - public void storeExectutionProgressTest(){ - OnapCommandExecutionStore.ExecutionStoreContext store=new OnapCommandExecutionStore.ExecutionStoreContext(); + public void storeExectutionProgressTest() { + OnapCommandExecutionStore.ExecutionStoreContext store = new OnapCommandExecutionStore.ExecutionStoreContext(); store.setExecutionId("abc"); store.setRequestId("abc"); store.setStorePath("abc"); - executionStore.storeExectutionProgress(store,"abc","abc","abc"); - assertTrue(new File(System.getProperty("user.dir")+File.separator+"abc").exists()); + executionStore.storeExectutionProgress(store, "abc", "abc", "abc"); + assertTrue(new File(System.getProperty("user.dir") + File.separator + "abc").exists()); } + @Test - public void storeExectutionDebugTest(){ - OnapCommandExecutionStore.ExecutionStoreContext store=new OnapCommandExecutionStore.ExecutionStoreContext(); + public void storeExectutionDebugTest() { + OnapCommandExecutionStore.ExecutionStoreContext store = new OnapCommandExecutionStore.ExecutionStoreContext(); store.setExecutionId("abc"); store.setRequestId("abc"); store.setStorePath("abc"); - executionStore.storeExectutionDebug(store,"abc"); - assertTrue(new File(System.getProperty("user.dir")+File.separator+"abc").exists()); + executionStore.storeExectutionDebug(store, "abc"); + assertTrue(new File(System.getProperty("user.dir") + File.separator + "abc").exists()); } + @Test - public void storeExectutionOutputTest(){ - OnapCommandExecutionStore.ExecutionStoreContext store=new OnapCommandExecutionStore.ExecutionStoreContext(); + public void storeExectutionOutputTest() { + OnapCommandExecutionStore.ExecutionStoreContext store = new OnapCommandExecutionStore.ExecutionStoreContext(); store.setExecutionId("abc"); store.setRequestId("abc"); store.setStorePath("abc"); - executionStore.storeExectutionOutput(store,"abc"); - assertTrue(new File(System.getProperty("user.dir")+File.separator+"abc").exists()); + executionStore.storeExectutionOutput(store, "abc"); + assertTrue(new File(System.getProperty("user.dir") + File.separator + "abc").exists()); + } + + + + @AfterClass + public static void tearDown() throws Exception { + String dirPath = System.getProperty("user.dir") + File.separator + "abc"; + String dirPathForExecutions = System.getProperty("user.dir") + File.separator + "data/executions"; + File file = new File(dirPath); + File executionsDir = new File(dirPathForExecutions); + assertTrue(OnapCommandExceutionListCommandTest.deleteDirectory(file)); + assertTrue(OnapCommandExceutionListCommandTest.deleteDirectory(executionsDir)); } }
\ No newline at end of file |