Extract class StopWatch from ApiService
[dmaap/dbcapi.git] / src / test / java / org / onap / dmaap / dbcapi / service / StopWatchTest.java
diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/StopWatchTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/StopWatchTest.java
new file mode 100644 (file)
index 0000000..b4b6af2
--- /dev/null
@@ -0,0 +1,49 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.dmaap\r
+ * ================================================================================\r
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.onap.dmaap.dbcapi.service;\r
+\r
+import static org.junit.Assert.assertThat;\r
+import static org.junit.Assert.assertTrue;\r
+import static org.junit.Assert.assertEquals;\r
+import org.junit.Test;\r
+import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;\r
+\r
+public class StopWatchTest extends BaseLoggingClass {\r
+\r
+    private StopWatch stopWatch = new StopWatch();\r
+\r
+    @Test\r
+    public void stopWatchShouldReturnElapsedTime() throws InterruptedException {\r
+        stopWatch.start();\r
+        Thread.sleep(50);\r
+        stopWatch.stop();\r
+        assertTrue(stopWatch.getElapsedTime() > 0);\r
+    }\r
+\r
+    @Test\r
+    public void resetShouldSetElapsedTime() {\r
+        stopWatch.start();\r
+        stopWatch.stop();\r
+        stopWatch.resetElapsedTime();\r
+        assertEquals(0,stopWatch.getElapsedTime());\r
+\r
+    }\r
+\r
+}
\ No newline at end of file