diff --git a/pom.xml b/pom.xml index 8c66974..383a78f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.fross quoter - 5.0.10 + 5.0.11 jar quoter diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index e7a9284..c7da6a8 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: quoter -version: '5.0.10' +version: '5.0.11' summary: Command line utility to pull stock and index quotes description: | Quoter fetches online stock quotes and index data for easy display on diff --git a/src/main/java/org/fross/quoter/HistoricalQuotes.java b/src/main/java/org/fross/quoter/HistoricalQuotes.java index 4fbb579..1f958b1 100644 --- a/src/main/java/org/fross/quoter/HistoricalQuotes.java +++ b/src/main/java/org/fross/quoter/HistoricalQuotes.java @@ -248,7 +248,7 @@ public void displayTrend(String symb) { // Display the symbol informational header Output.printColorln(Ansi.Color.WHITE, "\n\n+--" + NUM_DAYS_IN_TREND + " Day Trend" + "-".repeat(graphWidth - String.valueOf(NUM_DAYS_IN_TREND).length() + 8) + "+"); - Output.printColorln(Ansi.Color.YELLOW, symb.toUpperCase()); + Output.printColorln(Ansi.Color.YELLOW, symb.toUpperCase() + " : " + symbolData.get("fullname")); Output.printColorln(Ansi.Color.YELLOW, "Current Price: " + symbolData.get("latestPrice")); Output.printColorln(Ansi.Color.YELLOW, NUM_DAYS_IN_TREND + " Day Low: " + String.format("%,.2f", sv)); Output.printColorln(Ansi.Color.YELLOW, NUM_DAYS_IN_TREND + " Day High: " + String.format("%,.2f", lv)); diff --git a/src/main/java/org/fross/quoter/Symbol.java b/src/main/java/org/fross/quoter/Symbol.java index e617947..c0f2d51 100644 --- a/src/main/java/org/fross/quoter/Symbol.java +++ b/src/main/java/org/fross/quoter/Symbol.java @@ -206,6 +206,11 @@ private void getSymbolData(String symb) { xPath = "/html/body/div[3]/div[2]/div[3]/div/div[1]/span/bg-quote"; result = queryPageItem(htmlPage, xPath); symbolData.put("timeStamp", result.replaceAll("[,%]", "").trim()); + + // Full Name of Company + xPath = "/html/body/div[3]/div[2]/div[2]/div/div[2]/h1"; + result = queryPageItem(htmlPage, xPath); + symbolData.put("fullname", result.trim()); } else { // Market is OPEN @@ -272,6 +277,11 @@ private void getSymbolData(String symb) { xPath = "/html/body/div[3]/div[2]/div[3]/div/div[1]/span/bg-quote"; result = queryPageItem(htmlPage, xPath); symbolData.put("timeStamp", result.replaceAll("[,%]", "").trim()); + + // Full Name of Company + xPath = "/html/body/div[3]/div[2]/div[2]/div/div[2]/h1"; + result = queryPageItem(htmlPage, xPath); + symbolData.put("fullname", result.trim()); } // If we are in debug mode, display the values of the symbol diff --git a/src/test/java/org/fross/quoter/SymbolTest.java b/src/test/java/org/fross/quoter/SymbolTest.java index 025d64f..8750282 100644 --- a/src/test/java/org/fross/quoter/SymbolTest.java +++ b/src/test/java/org/fross/quoter/SymbolTest.java @@ -26,6 +26,7 @@ ***************************************************************************************************************/ package org.fross.quoter; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.fail; @@ -35,10 +36,11 @@ class SymbolTest { // Look through a list of symbols and ensure all the right fields are present @Test - void test() { + void testFields() { String[] testSymbols = { "IBM", "TSLA", "GOOG" }; + String[] symbolFullName = { "International Business Machines Corp.", "Tesla Inc.", "Alphabet Inc. Cl C" }; String[] testFields = { "symbol", "latestPrice", "change", "changePercent", "dayHigh", "dayLow", "ytdChangePercent", "oneYearChangePercent", - "timeStamp", "week52High", "week52Low", "status" }; + "timeStamp", "week52High", "week52Low", "fullname", "status" }; // Loop through each symbol we are testing for (int i = 0; i < testSymbols.length; i++) { @@ -53,8 +55,9 @@ void test() { fail("'" + testFields[i] + "' does not exist"); } } - } + // Since the names shouldn't change, lets test a few of the fullname fields + assertEquals(symb.get("fullname"), symbolFullName[i]); + } } - }