51 lines
1.3 KiB
Groovy
51 lines
1.3 KiB
Groovy
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() { }
|
|
|
|
void "test we can parse company with CVR 25063864"() {
|
|
|
|
when:
|
|
def testFile = new File(getClass().getResource('/25063864.json').toURI())
|
|
def testJson = testFile.getText('UTF-8')
|
|
def company = api.parseJsonIntoCompany(testJson)
|
|
|
|
then:
|
|
company != null
|
|
company.vat == 25063864
|
|
company.life.name == 'AGILLIC A/S'
|
|
company.secondarynames.contains('Wavetech A/S')
|
|
company.info.employment.amountEmployeesLow == 50
|
|
company.info.employment.amountEmployeesHigh == 99
|
|
}
|
|
|
|
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 ?
|
|
|
|
}
|
|
|