-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1052 adding test for loading basket constituent csv file and handlin…
…g when it errors & sourcing test resources for test
- Loading branch information
Showing
4 changed files
with
109 additions
and
28 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,4 @@ | ||
Symbol,Name,Last Trade,Change,Volume, Weighting | ||
AAL.L,Anglo American PLC,436.35,5.35,5799089,0.0278736825813547 | ||
ABF.L,Associated British Foods PLC,435.60,7.40,86808,0.000417248060431947 | ||
ADM.L,Admiral Group PLC,1,627.00,,86808,0.000417248060431947 |
4 changes: 4 additions & 0 deletions
4
example/basket/src/test/resources/constituents/ftsewitherror.csv
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,4 @@ | ||
Symbol,Name,Last Trade,Change,Volume, Weighting | ||
AAL.L,Anglo American PLC,436.35,5.35,5799089,0.0278736825813547 | ||
ABF.L,Associated British Foods PLC,435.60,7.40,86808,NotANumber | ||
ADM.L,Admiral Group PLC,1,627.00,,86808,0.000417248060431947 |
47 changes: 47 additions & 0 deletions
47
example/basket/src/test/scala/org/finos/vuu/csv/CsvStaticLoaderTests.scala
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 org.finos.vuu.csv | ||
|
||
import org.finos.vuu.core.module.basket.csv.CsvStaticLoader | ||
import org.scalatest.featurespec.AnyFeatureSpec | ||
|
||
import scala.io.Source | ||
|
||
class CsvStaticLoaderTests extends AnyFeatureSpec{ | ||
|
||
Feature("CSV loading Test Case") { | ||
|
||
Scenario("Can successfully load and parse basket constituents") { | ||
var path = getClass.getResource("/constituents") | ||
//his.class.getResourceAsStream("/myfile") | ||
var x = ClassLoader.getSystemResource("") | ||
// var x = Source.fromURL(path) | ||
// var B = Source.fromResource("/static") | ||
val testResourcePath = this.getClass().getResource("/constituents").getPath | ||
val constituents = CsvStaticLoader.loadConstituent(".FTSE100", Some(testResourcePath)) | ||
|
||
assert(constituents.length == 3) | ||
val firstRow = constituents.head | ||
assert(firstRow("Symbol") == "AAL.L") | ||
assert(firstRow("Last Trade") == "436.35") | ||
assert(firstRow("Name") == "Anglo American PLC") | ||
assert(firstRow("Weighting") == 0.0278736825813547) | ||
assert(firstRow("Volume") == "5799089") | ||
assert(firstRow("Change") == "5.35") | ||
} | ||
|
||
Scenario("When parsing basket constituents fails return empty") { | ||
|
||
val constituents = CsvStaticLoader.loadConstituent(".FTSEWithError") | ||
|
||
assert(constituents.length == 0) | ||
} | ||
|
||
|
||
Scenario("When no matching basket constituents file return empty") { | ||
|
||
val constituents = CsvStaticLoader.loadConstituent(".NoSuchFile") | ||
|
||
assert(constituents.length == 0) | ||
} | ||
|
||
} | ||
} |