Search in sources :

Example 6 with DisabledIfEnvironmentVariable

use of org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable in project jgnash by ccavanaugh.

the class IEXParserTest method testHistoricalDownload.

@Test
// disable on Travis-CI
@DisabledIfEnvironmentVariable(named = "CI", matches = "true")
void testHistoricalDownload() throws IOException {
    if (System.getenv(GITHUB_ACTION) != null) {
        // don't test with Github actions
        return;
    }
    // test env must be configured with a valid token
    if (System.getenv(TEST_TOKEN) == null) {
        // don't test with Github actions
        return;
    }
    final SecurityNode ibm = new SecurityNode(e.getDefaultCurrency());
    ibm.setSymbol("IBM");
    ibm.setScale((byte) 2);
    ibm.setQuoteSource(QuoteSource.IEX_CLOUD);
    e.addSecurity(ibm);
    final QuoteSource quoteSource = ibm.getQuoteSource();
    assertNotNull(quoteSource);
    final SecurityParser securityParser = quoteSource.getParser();
    assertNotNull(securityParser);
    assertThat(securityParser, instanceOf(IEXParser.class));
    ((IEXParser) securityParser).setUseSandbox();
    securityParser.setTokenSupplier(() -> System.getenv(TEST_TOKEN));
    final List<SecurityHistoryNode> events = securityParser.retrieveHistoricalPrice(ibm, LocalDate.of(2019, Month.JANUARY, 2), LocalDate.of(2019, Month.MARCH, 1));
    assertNotNull(events);
    assertEquals(41, events.size());
}
Also used : IEXParser(jgnash.net.security.iex.IEXParser) SecurityNode(jgnash.engine.SecurityNode) SecurityHistoryNode(jgnash.engine.SecurityHistoryNode) QuoteSource(jgnash.engine.QuoteSource) SecurityParser(jgnash.net.security.SecurityParser) AbstractEngineTest(jgnash.engine.AbstractEngineTest) Test(org.junit.jupiter.api.Test) DisabledIfEnvironmentVariable(org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)

Example 7 with DisabledIfEnvironmentVariable

use of org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable in project jgnash by ccavanaugh.

the class IEXParserTest method testHistoricalSplitsDownload.

@Test
// disable on Travis-CI
@DisabledIfEnvironmentVariable(named = "CI", matches = "true")
void testHistoricalSplitsDownload() throws IOException {
    if (System.getenv(GITHUB_ACTION) != null) {
        // don't test with Github actions
        return;
    }
    // test env must be configured with a valid token
    if (System.getenv(TEST_TOKEN) == null) {
        // don't test with Github actions
        return;
    }
    final SecurityNode pstv = new SecurityNode(e.getDefaultCurrency());
    pstv.setSymbol("PSTV");
    pstv.setScale((byte) 2);
    pstv.setQuoteSource(QuoteSource.IEX_CLOUD);
    e.addSecurity(pstv);
    final QuoteSource quoteSource = pstv.getQuoteSource();
    assertNotNull(quoteSource);
    final SecurityParser securityParser = quoteSource.getParser();
    assertNotNull(securityParser);
    assertThat(securityParser, instanceOf(IEXParser.class));
    ((IEXParser) securityParser).setUseSandbox();
    securityParser.setTokenSupplier(() -> System.getenv(TEST_TOKEN));
    final Set<SecurityHistoryEvent> historicalEvents = securityParser.retrieveHistoricalEvents(pstv, LocalDate.of(2015, Month.JANUARY, 1));
    assertNotNull(historicalEvents);
    assertEquals(1, historicalEvents.size());
}
Also used : IEXParser(jgnash.net.security.iex.IEXParser) SecurityNode(jgnash.engine.SecurityNode) QuoteSource(jgnash.engine.QuoteSource) SecurityParser(jgnash.net.security.SecurityParser) SecurityHistoryEvent(jgnash.engine.SecurityHistoryEvent) AbstractEngineTest(jgnash.engine.AbstractEngineTest) Test(org.junit.jupiter.api.Test) DisabledIfEnvironmentVariable(org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)

Aggregations

Test (org.junit.jupiter.api.Test)7 DisabledIfEnvironmentVariable (org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)7 AbstractEngineTest (jgnash.engine.AbstractEngineTest)5 SecurityNode (jgnash.engine.SecurityNode)5 QuoteSource (jgnash.engine.QuoteSource)4 SecurityParser (jgnash.net.security.SecurityParser)4 SecurityHistoryEvent (jgnash.engine.SecurityHistoryEvent)3 SecurityHistoryNode (jgnash.engine.SecurityHistoryNode)3 IEXParser (jgnash.net.security.iex.IEXParser)3 Disabled (org.junit.jupiter.api.Disabled)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 OkHttpClient (okhttp3.OkHttpClient)1 Response (okhttp3.Response)1