- Add the Codota plugin to your IDE and get smart completions
private void myMethod () {Connection c =
DataSource dataSource;dataSource.getConnection()
String url;DriverManager.getConnection(url)
IdentityDatabaseUtil.getDBConnection()
- Smart code suggestions by Codota
}
@Test(expectedExceptions = QuandlRuntimeException.class) public final void testDataSetRequestFrequency() { DataSetRequest.Builder.of("Hello").withFrequency(null).build(); }
@Test public void testMostComplexGetDataSetDifferentOrder() { // now try a different order QuandlSession session = getTestSession("https://www.quandl.com/api/v3/datasets/WIKI/AAPL.csv?start_date=2009-01-01&end_date=2010-12-31&column_index=4&collapse=quarterly&limit=10&transform=normalize"); TabularResult tabularResult = session.getDataSet(DataSetRequest.Builder.of("WIKI/AAPL") .withFrequency(Frequency.QUARTERLY) .withColumn(CLOSE_COLUMN) .withStartDate(LocalDate.of(2009, 1, 1)) .withEndDate(LocalDate.of(2010, 12, 31)) .withMaxRows(10) .withTransform(Transform.NORMALIZE) .build()); Assert.assertEquals(TEST_TABULAR_RESULT, tabularResult); }
@Test public final void testComplexDataSetRequestEqualsAndHashCodeAgainstStringAndObject() { // 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. DataSetRequest request1 = DataSetRequest.Builder .of("CODE/CODE") .withColumn(3) .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 public void testMoreComplexGetDataSet() { ClassicQuandlSessionInterface session = getTestSession("https://www.quandl.com/api/v3/datasets/WIKI/AAPL.csv?column_index=4&collapse=quarterly&transform=normalize"); TabularResult tabularResult = session.getDataSet(DataSetRequest.Builder.of("WIKI/AAPL") .withFrequency(Frequency.QUARTERLY) .withColumn(CLOSE_COLUMN) .withTransform(Transform.NORMALIZE) .build()); Assert.assertEquals(TEST_TABULAR_RESULT, tabularResult); }
@Test(expectedExceptions = QuandlRuntimeException.class) public final void testDataSetRequestSortOrder() { DataSetRequest.Builder.of("Hello").withSortOrder(null).build(); }
@Test(expectedExceptions = QuandlRuntimeException.class) public final void testDataSetRequestEndDate() { DataSetRequest.Builder.of("Hello").withEndDate(null).build(); }
@Test(expectedExceptions = QuandlRuntimeException.class) public final void testDataSetRequestStartDate() { DataSetRequest.Builder.of("Hello").withStartDate(null).build(); }
@Test(expectedExceptions = QuandlRuntimeException.class) public final void testDataSetRequestEndDate() { DataSetRequest.Builder.of("Hello").withEndDate(null).build(); }
@Test(expectedExceptions = QuandlRuntimeException.class) public final void testDataSetRequestTransform() { DataSetRequest.Builder.of("Hello").withTransform(null).build(); }
@Test(expectedExceptions = QuandlRuntimeException.class) public final void testDataSetRequestFrequency() { DataSetRequest.Builder.of("Hello").withFrequency(null).build(); }
@Test(expectedExceptions = QuandlRuntimeException.class) public final void testDataSetRequestStartDate() { DataSetRequest.Builder.of("Hello").withStartDate(null).build(); }
@Test public final void testComplexDataSetRequestEqualsAndHashCodeAgainstStringAndObject() { // 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. DataSetRequest request1 = DataSetRequest.Builder .of("CODE/CODE") .withColumn(3) .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()); }
/** * The main body of the code. */ private void run() { ClassicQuandlSession session = ClassicQuandlSession.create(); TabularResult tabularResult = session.getDataSet( DataSetRequest.Builder .of("WIKI/AAPL") .withFrequency(Frequency.QUARTERLY) .withColumn(CLOSE_COLUMN) .withTransform(Transform.NORMALIZE) .build()); System.out.println(tabularResult.toPrettyPrintedString()); }
/** * The main body of the code. */ private void run() { ClassicQuandlSession quandl = ClassicQuandlSession.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)); MetaDataResult metaData = quandl.getMetaData(MetaDataRequest.of("WIKI/AAPL")); System.out.println(PrettyPrinter.toPrettyPrintedString(metaData.getRawJSON())); }
@Test public void testMostComplexGetDataSetDifferentOrder() { // now try a different order ClassicQuandlSessionInterface session = getTestSession("https://www.quandl.com/api/v3/datasets/WIKI/AAPL.csv?start_date=2009-01-01&end_date=2010-12-31&column_index=4&collapse=quarterly&limit=10&transform=normalize"); TabularResult tabularResult = session.getDataSet(DataSetRequest.Builder.of("WIKI/AAPL") .withFrequency(Frequency.QUARTERLY) .withColumn(CLOSE_COLUMN) .withStartDate(LocalDate.of(2009, 1, 1)) .withEndDate(LocalDate.of(2010, 12, 31)) .withMaxRows(10) .withTransform(Transform.NORMALIZE) .build()); Assert.assertEquals(TEST_TABULAR_RESULT, tabularResult); }
/** * The main body of the code. */ private void run() { ClassicQuandlSession session = ClassicQuandlSession.create(); TabularResult tabularResult = session.getDataSet( DataSetRequest.Builder .of("SSE/VROS") // VERIANOS REAL ESTATE AG on Boerse Stuttgart .withColumn(3) // Last (looked up previously) .withStartDate(RECENTISH_DATE) .withFrequency(Frequency.MONTHLY) .build()); System.out.println("Header definition: " + tabularResult.getHeaderDefinition()); for (final Row row : tabularResult) { LocalDate date = row.getLocalDate("Date"); Double value = row.getDouble("Last"); System.out.println("Value on date " + date + " was " + value); } }
@Test(expectedExceptions = QuandlRuntimeException.class) public final void testDataSetRequestTransform() { DataSetRequest.Builder.of("Hello").withTransform(null).build(); }
@Test public final void testSimpleDataSetRequestEqualsAndHashCode() { DataSetRequest request1 = DataSetRequest.Builder.of("Hello").build(); DataSetRequest request2 = DataSetRequest.Builder.of("Hello").build(); DataSetRequest request3 = DataSetRequest.Builder.of("Goodbye").build(); Assert.assertEquals(request1, request1); Assert.assertEquals(request1.hashCode(), request1.hashCode()); Assert.assertEquals(request2, request1); Assert.assertEquals(request2.hashCode(), request1.hashCode()); Assert.assertNotEquals(request3, request1); Assert.assertNotEquals(request3, request2); Assert.assertNotEquals(request1, null); Assert.assertNotEquals(request2, null); Assert.assertNotEquals(request3, null); Assert.assertEquals(request3.hashCode(), request3.hashCode()); Assert.assertNotEquals(request3.hashCode(), request2.hashCode()); // we can't assert that }