libcvrapi/src/test/groovy/biz/nellemann/libcvrapi/CvrApiSpec.groovy

51 lines
1.3 KiB
Groovy
Raw Normal View History

2019-08-17 17:53:11 +00:00
package biz.nellemann.libcvrapi
import spock.lang.Specification
class CvrApiSpec extends Specification {
CvrApi api
def setup() {
api = new CvrApi("Test User Agent", "testAuthToken")
}
def cleanup() { }
2019-08-23 06:18:13 +00:00
void "test we can parse company with CVR 25063864"() {
2019-08-17 17:53:11 +00:00
when:
2019-08-23 06:18:13 +00:00
def testFile = new File(getClass().getResource('/25063864.json').toURI())
def testJson = testFile.getText('UTF-8')
def company = api.parseJsonIntoCompany(testJson)
2019-08-17 17:53:11 +00:00
then:
2019-08-19 18:58:01 +00:00
company != null
2019-08-17 17:53:11 +00:00
company.vat == 25063864
company.life.name == 'AGILLIC A/S'
2019-08-19 08:00:01 +00:00
company.secondarynames.contains('Wavetech A/S')
2019-08-19 18:58:01 +00:00
company.info.employment.amountEmployeesLow == 50
company.info.employment.amountEmployeesHigh == 99
2019-08-17 17:53:11 +00:00
}
2019-08-23 06:18:13 +00:00
void "test we can parse company with CVR 15027800"() {
when:
def testFile = new File(getClass().getResource('/15027800.json').toURI())
def testJson = testFile.getText('UTF-8')
def company = api.parseJsonIntoCompany(testJson)
then:
company != null
company.vat == 15027800
company.life.name == 'FREJA TRANSPORT & LOGISTICS A/S'
company.secondarynames.contains('KT TRANSPORT A/S')
company.info.employment.amountEmployeesLow == 200
company.info.employment.amountEmployeesHigh == 499
}
// TODO: Get better code coverage in tests, eg. by mocking okHttp interface - but how ?
2019-08-17 17:53:11 +00:00
}