MultiDataSetRequest req = fuzz(MultiDataSetRequest.Builder.of(chunk)).build(); try { TabularResult dataSet = session.getDataSets(req);
@Test public void testComplexMultiDataSetRequestEqualsAndHashCodeAgainstStringAndObject() { // Note that the tests on hashCode here are beyond the contract requirements of hashCode, we're saying they must differ if the object differs, which is // generally good, but not required. MultiDataSetRequest request1 = MultiDataSetRequest.Builder .of(QuandlCodeRequest.allColumns("CODE/CODE")) .withFrequency(Frequency.NONE) .withMaxRows(49) .withSortOrder(SortOrder.ASCENDING) .withStartDate(LocalDate.of(2010, 1, 1)) .withEndDate(LocalDate.of(2011, 1, 1)) .build(); Assert.assertNotEquals(request1, "Hello"); Assert.assertNotEquals(request1, new Object()); }
@Test(expectedExceptions = QuandlRuntimeException.class) public void testLargeMultiDataSetRequestWithEmpty() { QuandlSession session = getTestSession("https://www.quandl.com/api/v3/multisets.csv?columns=&collapse=monthly&transformation=normalize"); TabularResult tabularResult = session.getDataSets( // expect an exception here because list is empty MultiDataSetRequest.Builder.of() .withFrequency(Frequency.MONTHLY) .withTransform(Transform.NORMALIZE) .build()); Assert.assertEquals(TEST_TABULAR_RESULT, tabularResult); }
.withStartDate(LocalDate.of(2010, 1, 1)) .withEndDate(LocalDate.of(2011, 1, 1)) .build(); .withStartDate(LocalDate.of(2010, 1, 1)) .withEndDate(LocalDate.of(2011, 1, 1)) .build(); Assert.assertEquals(request2, request2); Assert.assertNotEquals(request1, request2); .withStartDate(LocalDate.of(2010, 1, 1)) .withEndDate(LocalDate.of(2011, 1, 1)) .build(); Assert.assertEquals(request3, request3); Assert.assertNotEquals(request1, request3); .withStartDate(LocalDate.of(2010, 1, 1)) .withEndDate(LocalDate.of(2011, 1, 1)) .build(); Assert.assertEquals(request4, request4); Assert.assertNotEquals(request1, request4); .withStartDate(LocalDate.of(2010, 1, 1)) .withEndDate(LocalDate.of(2011, 1, 1)) .build(); Assert.assertEquals(request5, request5); Assert.assertNotEquals(request1, request5); .withStartDate(LocalDate.of(2010, 1, 1))
/** * The main body of the code. */ private void run() { QuandlSession quandl = QuandlSession.create(); SearchResult searchResult = quandl.search(SearchRequest.Builder.ofQuery("Apple").withMaxPerPage(2).build()); System.out.println(searchResult.toPrettyPrintedString()); for (MetaDataResult metaData : searchResult.getMetaDataResultList()) { System.out.println(PrettyPrinter.toPrettyPrintedString(metaData.getRawJSON())); } TabularResult tabularResult = null; tabularResult = quandl.getDataSet(DataSetRequest.Builder.of("WIKI/AAPL").withFrequency(Frequency.QUARTERLY) .withColumn(CLOSE_COLUMN).withTransform(Transform.NORMALIZE).build()); System.out.println(PrettyPrinter.toPrettyPrintedString(tabularResult)); TabularResult tabularResultMulti = quandl.getDataSets( MultiDataSetRequest.Builder.of( QuandlCodeRequest.allColumns("WIKI/AAPL"), QuandlCodeRequest.allColumns("DOE/RWTC") ).withStartDate(RECENTISH_DATE) .build()); System.out.println(PrettyPrinter.toPrettyPrintedString(tabularResultMulti)); MetaDataResult metaData = quandl.getMetaData(MetaDataRequest.of("WIKI/AAPL")); System.out.println(PrettyPrinter.toPrettyPrintedString(metaData.getRawJSON())); MetaDataResult metaData2 = quandl.getMetaData(MultiMetaDataRequest.of("WIKI/AAPL", "DOE/RWTC", "WIKI/MSFT")); System.out.println(PrettyPrinter.toPrettyPrintedString(metaData2.getRawJSON())); }
/** * The main body of the code. */ private void run() { QuandlSession session = QuandlSession.create(); TabularResult tabularResultMulti = session.getDataSets( MultiDataSetRequest.Builder .of( QuandlCodeRequest.singleColumn("WIKI/AAPL", CLOSE_COLUMN), QuandlCodeRequest.allColumns("DOE/RWTC") ) .withStartDate(RECENTISH_DATE) .withFrequency(Frequency.MONTHLY) .build()); System.out.println("Header definition: " + tabularResultMulti.getHeaderDefinition()); Iterator<Row> iter = tabularResultMulti.iterator(); while (iter.hasNext()) { Row row = iter.next(); LocalDate date = row.getLocalDate("Date"); Double value = row.getDouble("DOE/RWTC - Value"); System.out.println("Value on date " + date + " was " + value); } }
/** * The main body of the code. */ private void run() { QuandlSession session = QuandlSession.create(); TabularResult tabularResultMulti = session.getDataSets( MultiDataSetRequest.Builder .of( QuandlCodeRequest.singleColumn("WIKI/AAPL", CLOSE_COLUMN), QuandlCodeRequest.allColumns("DOE/RWTC") ) .withStartDate(RECENTISH_DATE) .withFrequency(Frequency.MONTHLY) .build()); System.out.println(tabularResultMulti.toPrettyPrintedString()); }
@Test(expectedExceptions = QuandlRuntimeException.class) public final void testMultiDataSetRequestTransform() { MultiDataSetRequest.Builder.of(QuandlCodeRequest.allColumns("Hello")).withTransform(null).build(); }
@Test(expectedExceptions = QuandlRuntimeException.class) public final void testMultiDataSetRequestSortOrder() { MultiDataSetRequest.Builder.of(QuandlCodeRequest.allColumns("Hello")).withSortOrder(null).build(); }
@Test(expectedExceptions = QuandlRuntimeException.class) public final void testMultiDataSetRequestFrequency() { MultiDataSetRequest.Builder.of(QuandlCodeRequest.allColumns("Hello")).withFrequency(null).build(); }
@Test(expectedExceptions = QuandlRuntimeException.class) public final void testMultiDataSetRequestStartDate() { MultiDataSetRequest.Builder.of(QuandlCodeRequest.allColumns("Hello")).withStartDate(null).build(); }
@Test(expectedExceptions = QuandlRuntimeException.class) public final void testMultiDataSetRequestEndDate() { MultiDataSetRequest.Builder.of(QuandlCodeRequest.allColumns("Hello")).withEndDate(null).build(); }