-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from flygare/adding_unit_tests
Adding unit tests
- Loading branch information
Showing
15 changed files
with
121 additions
and
14 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
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
6 changes: 4 additions & 2 deletions
6
src/main/scala/DBConnector.scala → ...la/se/qvantel/connector/DBConnector.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
7 changes: 5 additions & 2 deletions
7
src/main/scala/DatapointDispatcher.scala → ...antel/connector/DatapointDispatcher.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
2 changes: 2 additions & 0 deletions
2
src/main/scala/SparkConnection.scala → ...e/qvantel/connector/SparkConnection.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
2 changes: 1 addition & 1 deletion
2
src/main/scala/model/Country.scala → .../se/qvantel/connector/model/Country.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package model | ||
package se.qvantel.connector.model | ||
|
||
case class Country(network: String, country: String, mcc: String, iso: String, country_code: String, mnc: String) |
2 changes: 1 addition & 1 deletion
2
src/main/scala/property/Config.scala → ...e/qvantel/connector/property/Config.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package property | ||
package se.qvantel.connector.property | ||
|
||
import com.typesafe.config.ConfigFactory | ||
|
||
|
4 changes: 2 additions & 2 deletions
4
src/main/scala/property/CountryCodes.scala → ...tel/connector/property/CountryCodes.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
2 changes: 1 addition & 1 deletion
2
src/main/scala/property/Logger.scala → ...e/qvantel/connector/property/Logger.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package property | ||
package se.qvantel.connector.property | ||
|
||
|
||
trait Logger { | ||
|
2 changes: 1 addition & 1 deletion
2
src/main/scala/property/Processing.scala → ...antel/connector/property/Processing.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package property | ||
package se.qvantel.connector.property | ||
|
||
|
||
trait Processing extends Config { | ||
|
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 @@ | ||
gen.countries.file="/mcc-mnc-table.json" |
45 changes: 45 additions & 0 deletions
45
src/test/scala/se/qvantel/connector/model/CountryTest.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,45 @@ | ||
package se.qvantel.connector.model | ||
|
||
import org.json4s.DefaultFormats | ||
import org.scalatest.FunSuite | ||
import org.json4s.native.JsonMethods._ | ||
|
||
|
||
class CountryTest extends FunSuite { | ||
|
||
test("Test parsing of JSON-string to model.Country case class") { | ||
val string = "[" + | ||
"{\"network\":\"A-Mobile\",\"country\":\"Abkhazia\",\"mcc\":\"289\",\"iso\":\"ge\"," + | ||
"\"country_code\":\"7\",\"mnc\":\"68\"}," + | ||
"{\"network\":\"A-Mobile\",\"country\":\"Abkhazia\"," + | ||
"\"mcc\":\"289\",\"iso\":\"ge\",\"country_code\":\"7\",\"mnc\":\"88\"}," + | ||
"{\"network\":\"Aquafon\"," + | ||
"\"country\":\"Abkhazia\",\"mcc\":\"289\",\"iso\":\"ge\",\"country_code\":\"7\",\"mnc\":\"67\"}" + | ||
"{\"network\":\"BCELL\"," + | ||
"\"country\":\"Belgium\",\"mcc\":\"100\",\"iso\":\"ge\",\"country_code\":\"8\",\"mnc\":\"67\"}" + | ||
"]" | ||
|
||
// Specify format method | ||
implicit val format = DefaultFormats | ||
|
||
// Parse the object | ||
val obj = parse(string).extract[List[Country]] | ||
|
||
// Cherry picked testing. | ||
assert(obj.head.network.equals("A-Mobile")) | ||
assert(obj.head.country.equals("Abkhazia")) | ||
assert(obj.head.mcc.equals("289")) | ||
|
||
assert(obj(1).network.equals("A-Mobile")) | ||
assert(obj(1).country.equals("Abkhazia")) | ||
assert(obj(1).mcc.equals("289")) | ||
|
||
assert(obj(2).network.equals("Aquafon")) | ||
assert(obj(2).country.equals("Abkhazia")) | ||
assert(obj(2).mcc.equals("289")) | ||
|
||
assert(obj(3).network.equals("BCELL")) | ||
assert(obj(3).country.equals("Belgium")) | ||
assert(obj(3).mcc.equals("100")) | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/test/scala/se/qvantel/connector/property/CountryCodesTest.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,38 @@ | ||
package se.qvantel.connector.property | ||
|
||
import java.io.InputStream | ||
import org.scalatest.FunSuite | ||
|
||
class CountryCodesTest extends FunSuite with Config with CountryCodes { | ||
|
||
test("Check that there is a mcc-resources file") { | ||
try { | ||
val res = config.getString("gen.countries.file") | ||
|
||
val stream : InputStream = getClass.getResourceAsStream(res) | ||
val lines = scala.io.Source.fromInputStream(stream).mkString | ||
|
||
assert(lines.nonEmpty) | ||
stream.close() | ||
} | ||
catch { | ||
case ex: Exception => { | ||
fail(ex.getMessage()) | ||
} | ||
} | ||
} | ||
|
||
test("Mapping of mcc to country") { | ||
// Loads MCC and countries ISO code into a HashMap, variable in CountryCodes | ||
getCountriesByMcc() | ||
// Check we actually map something | ||
assert(!countries.isEmpty) | ||
// Check if code 240 is mapped to se (Sweden) | ||
val swedenISO = countries("240") | ||
assert(swedenISO == "se") | ||
// Check if code 432 is mapped to ir (Iran) | ||
val iranISO = countries("432") | ||
assert(iranISO == "ir") | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/test/scala/se/qvantel/connector/property/ProcessingTest.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,12 @@ | ||
package se.qvantel.connector.property | ||
|
||
import org.scalatest.FunSuite | ||
|
||
class ProcessingTest extends FunSuite with Processing { | ||
|
||
test("That a valid processing config exists") { | ||
assert(batchSize > 0 && batchSize <= 10000) | ||
assert(fetchBatchSize > 0 && fetchBatchSize <= 20000) | ||
assert(updateInterval > 0 && updateInterval <= 10000) | ||
} | ||
} |