-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
6d857b7
commit e3824a3
Showing
2 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package tech.tablesaw.plotly; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import tech.tablesaw.api.DateTimeColumn; | ||
import tech.tablesaw.api.DoubleColumn; | ||
import tech.tablesaw.api.Table; | ||
import tech.tablesaw.plotly.api.OHLCPlot; | ||
import tech.tablesaw.plotly.components.Figure; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class OhlcTest { | ||
|
||
@Test | ||
void ohlcPlotDoesNotThrowIllegalArgumentException() { | ||
// Test to fix bug reported at https://github.com/jtablesaw/tablesaw/issues/1237 | ||
String timeTitle = "time"; | ||
String openTitle = "open"; | ||
String closeTitle = "close"; | ||
String highTitle = "high"; | ||
String lowTitle = "low"; | ||
String graphTitle = "title"; | ||
|
||
LocalDateTime now = LocalDateTime.now(); | ||
List<LocalDateTime> time = List.of(now, now.plusSeconds(5), now.plusSeconds(10)); | ||
List<Double> open = List.of(1d, 2d, 3d); | ||
List<Double> close = List.of(1d, 2d, 3d); | ||
List<Double> high = List.of(1d, 2d, 3d); | ||
List<Double> low = List.of(1d, 2d, 3d); | ||
|
||
DateTimeColumn timeColumn = DateTimeColumn.create(timeTitle, time); | ||
DoubleColumn openColumn = DoubleColumn.create(openTitle, open); | ||
DoubleColumn closeColumn = DoubleColumn.create(closeTitle, close); | ||
DoubleColumn highColumn = DoubleColumn.create(highTitle, high); | ||
DoubleColumn lowColumn = DoubleColumn.create(lowTitle, low); | ||
|
||
Table priceTable = Table.create(timeColumn, openColumn, closeColumn, highColumn, lowColumn); | ||
Figure figure = OHLCPlot.create(graphTitle, priceTable, timeTitle, openTitle, highTitle, lowTitle, closeTitle); | ||
|
||
assertNotNull(figure); | ||
assertDoesNotThrow(() -> IllegalArgumentException.class); | ||
} | ||
} |