From cc3ebca12f5e2916bad967b9ccb064d4bbcff418 Mon Sep 17 00:00:00 2001 From: Seth Ladygo Date: Wed, 23 Jan 2019 12:21:04 -0800 Subject: [PATCH] Rename test to match refactoring of candlestick code --- ...st.java => TimeCandlestickWindowTest.java} | 56 +++---------------- 1 file changed, 9 insertions(+), 47 deletions(-) rename src/test/java/ats/plugin/{OHLCPlugInViewTest.java => TimeCandlestickWindowTest.java} (58%) diff --git a/src/test/java/ats/plugin/OHLCPlugInViewTest.java b/src/test/java/ats/plugin/TimeCandlestickWindowTest.java similarity index 58% rename from src/test/java/ats/plugin/OHLCPlugInViewTest.java rename to src/test/java/ats/plugin/TimeCandlestickWindowTest.java index d31b464..6524887 100644 --- a/src/test/java/ats/plugin/OHLCPlugInViewTest.java +++ b/src/test/java/ats/plugin/TimeCandlestickWindowTest.java @@ -1,20 +1,18 @@ package ats.plugin; -import ats.plugin.OHLCPlugInView; +import static org.junit.Assert.assertEquals; + +import org.joda.time.DateTime; import org.joda.time.Duration; -import org.joda.time.Instant; -import org.joda.time.Period; +import org.joda.time.format.DateTimeFormatter; +import org.joda.time.format.ISODateTimeFormat; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.junit.Assert.*; -import org.joda.time.format.DateTimeFormatter; -import org.joda.time.format.ISODateTimeFormat; -import org.joda.time.DateTime; -public class OHLCPlugInViewTest { - private static final Logger log = LoggerFactory.getLogger(OHLCPlugInViewTest.class); +public class TimeCandlestickWindowTest { + private static final Logger log = LoggerFactory.getLogger(TimeCandlestickWindowTest.class); private static DateTimeFormatter dateFormatter = ISODateTimeFormat.dateTime(); @@ -40,7 +38,7 @@ public class OHLCPlugInViewTest { Duration interval, String expected) { - DateTime l = OHLCPlugInView.makeWindowStartTime(currentTime, interval); + DateTime l = TimeCandlestickWindow.makeWindowStartTime(currentTime, interval); String start = dateFormatter.print(l); expected += ".000Z"; @@ -50,7 +48,6 @@ public class OHLCPlugInViewTest { // log.info("start time: {}", start); // log.info(" expected: {}", expected); - //assertEquals(interval.toString(), l.longValue(), Instant.parse("2018-05-15T13:23:00").getMillis()); assertEquals(interval.toString(), expected, start); } @@ -63,41 +60,6 @@ public class OHLCPlugInViewTest { } private void assertParseInterval(String str, Duration expected) { - assertEquals(OHLCPlugInView.parseInterval(str), expected); + assertEquals(TimeCandlestickWindow.parseInterval(str), expected); } - - /* - private static Long makeWindowStartTime(Long timestamp, Duration interval) { - long today = getDayStart(timestamp); - long intoToday = timestamp - today; - - // then modulo timestamp to find how far into the current window we'd be in - long intoPeriod = intoToday % interval.getMillis(); - - // then subtract modulo from current time to get window start - return timestamp - intoPeriod; - } - - private static long getDayStart(Long timestamp) { - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(timestamp); - cal.set(Calendar.HOUR, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - return cal.getTimeInMillis(); - } - - private static Long makeWindowEndTime(Long startTime, Duration interval) { - if (startTime == null || interval == null) return null; - - return startTime + interval.getMillis(); - } - - private boolean inWindow(Long timestamp) { - if (timestamp == null) return false; - - return timestamp >= windowStartTime && timestamp < windowEndTime; - } -*/ }