diff --git a/iris-api-tests/pom.xml b/iris-api-tests/pom.xml deleted file mode 100644 index 283a935b..00000000 --- a/iris-api-tests/pom.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - -4.0.0 - -net.contargo -iris-api-tests -1.0-SNAPSHOT - -jar - -IRIS API Tests - - - UTF-8 - UTF-8 - - 0.7-groovy-2.0 - 2.2.2 - 1.5 - 2.0 - 4.11 - 2.3 - 1.0.6 - 0.7.1 - - - - - - org.codehaus.gmaven - gmaven-plugin - ${gmavenVersion} - - ${gmavenProviderSelection} - UTF-8 - - - - - - testCompile - - - - - - org.codehaus.groovy - groovy-all - ${groovyVersion} - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.10 - - true - - - - exec-specs - test - - test - - - - **/*Spec.java - - false - - - - - - - - - - junit - junit-dep - ${junitVersion} - - - org.codehaus.groovy - groovy-all - ${groovyVersion} - - - org.spockframework - spock-core - ${spockCore} - test - - - org.codehaus.groovy - groovy-all - - - junit - junit-dep - - - org.hamcrest - hamcrest-core - - - - - org.codehaus.groovy.modules.http-builder - http-builder - ${httpBuilderVersion} - - - \ No newline at end of file diff --git a/iris-api-tests/src/test/groovy/address/AddressByAddressDetailsSpec.groovy b/iris-api-tests/src/test/groovy/address/AddressByAddressDetailsSpec.groovy deleted file mode 100644 index 33ef3323..00000000 --- a/iris-api-tests/src/test/groovy/address/AddressByAddressDetailsSpec.groovy +++ /dev/null @@ -1,83 +0,0 @@ -package address - -import spock.lang.Specification -import util.ClientFactory - -/** - * @author Arnold Franke - franke@synyx.de - */ -class AddressByAddressDetailsSpec extends Specification { - - def "request for addresses by details like street, city etc. "() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - and: "address details city, postal code and street" - def urlParams = [ - "city": "karlsruhe", - "postalcode": "76131", - "street": "hirtenweg", - "country": "DE" - ] - - when: "addresses by city, postal code and street are requested" - def response = client.get(path: "/api/geocodes", query: urlParams); - def listOfAddressLists = response.data.geoCodeResponse.addresses - def staticAddressesObject = listOfAddressLists[0] - def nominatimAddressesObject = listOfAddressLists[1] - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "there should be 4 objects in the response list" - listOfAddressLists.size() == 4 - - and: "the staticAddressesObject contains a parent address and a list of static addresses" - def parentAddressStatic = staticAddressesObject.parentAddress - def staticaddresses = staticAddressesObject.addresses - staticaddresses.size() >= 1 - - and: "the parent address object has certain attributes" - parentAddressStatic.size() == 10 - parentAddressStatic.keySet().containsAll("countryCode", "niceName", "displayName", "osmId", "placeId", "shortName", "address", "type", "longitude", "latitude") - parentAddressStatic.type == "ADDRESS" - - and: "a static address contains certain attributes" - def staticaddress = staticaddresses[0] - staticaddress.size() == 10 - staticaddress.keySet().containsAll("countryCode", "niceName", "displayName", "osmId", "placeId", "shortName", "address", "type", "longitude", "latitude") - - and: "the type of a static address is ADDRESS" - staticaddress.type == "ADDRESS" - - and: "a static address contains a address map with certain attributes" - def addressmapStatic = staticaddress.address - addressmapStatic.size() == 6 - addressmapStatic.keySet().containsAll("suburb", "static_id", "postcode", "country_code", "city", "hashkey") - - and: "the nominatimAddressesObject contains a parent address and a list of static addresses" - def parentAddressNominatim = nominatimAddressesObject.parentAddress - def nominatimaddresses = nominatimAddressesObject.addresses - nominatimaddresses.size() == 1 - - and: "the parent address object has certain attributes" - parentAddressNominatim.size() == 10 - parentAddressNominatim.keySet().containsAll("countryCode", "niceName", "displayName", "osmId", "placeId", "shortName", "address", "type", "longitude", "latitude") - parentAddressNominatim.type == "ADDRESS" - - and: "a nominatim address contains certain attributes" - def nominatimaddress = nominatimaddresses[0] - nominatimaddress.size() == 10 - nominatimaddress.keySet().containsAll("countryCode", "niceName", "displayName", "osmId", "placeId", "shortName", "address", "type", "longitude", "latitude") - - and: "the type of a nominatim address is ADDRESS" - nominatimaddress.type == "ADDRESS" - - and: "a nominatim address contains a address map with certain attributes" - def addressmapNominatim = nominatimaddress.address - addressmapNominatim.size() >= 8 - addressmapNominatim.keySet().containsAll("suburb", "postcode", "country_code", "city", "country", "road", "state_district", "state") - - } -} diff --git a/iris-api-tests/src/test/groovy/address/AddressByBestMatchSpec.groovy b/iris-api-tests/src/test/groovy/address/AddressByBestMatchSpec.groovy deleted file mode 100644 index 53985323..00000000 --- a/iris-api-tests/src/test/groovy/address/AddressByBestMatchSpec.groovy +++ /dev/null @@ -1,106 +0,0 @@ -package address - -import groovyx.net.http.HttpResponseException -import spock.lang.Specification -import util.ClientFactory - -/** - * @author Ben Antony - antony@synyx.de - */ -class AddressByBestMatchSpec extends Specification { - - def "request for addresses by details like city etc. matching a static address"() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - and: "address details city, postal code" - def urlParams = [ - "city": "karlsruhe", - "postalcode": "76131", - "countrycode": "DE" - ] - - when: "addresses by city and postal code are requested" - def response = client.get(path: "/api/addresses/bestmatch", query: urlParams); - def bestMatchAddressKarlsruhe = response.data - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "resulting address has all fields" - bestMatchAddressKarlsruhe.size() == 6 - bestMatchAddressKarlsruhe.keySet().containsAll("hashKey", "geoLocation","city", "countryCode", "postalCode", "suburb") - bestMatchAddressKarlsruhe.geoLocation.size() == 3 - bestMatchAddressKarlsruhe.geoLocation.keySet().containsAll("latitude", "longitude", "type") - - and: "resulting address is Karlsruhe" - bestMatchAddressKarlsruhe.hashKey == "D3YTD" - bestMatchAddressKarlsruhe.city == "Karlsruhe" - bestMatchAddressKarlsruhe.geoLocation.latitude == 49.0126538640 - bestMatchAddressKarlsruhe.geoLocation.longitude == 8.3770751953 - bestMatchAddressKarlsruhe.geoLocation.type == "GEOLOCATION" - bestMatchAddressKarlsruhe.countryCode == "DE" - bestMatchAddressKarlsruhe.postalCode == "76131" - bestMatchAddressKarlsruhe.suburb == "" - - } - - def "request for addresses by details like city etc. matching a not static address"() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - and: "address details city, postal code" - def urlParams = [ - "city": "Trier", - "postalcode": "54290", - "countrycode": "DE" - ] - - when: "addresses by city and postal code are requested" - def response = client.get(path: "/api/addresses/bestmatch", query: urlParams); - def bestMatchAddressKarlsruhe = response.data - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "resulting address has all fields" - bestMatchAddressKarlsruhe.size() == 6 - bestMatchAddressKarlsruhe.keySet().containsAll("hashKey", "geoLocation","city", "countryCode", "postalCode", "suburb") - bestMatchAddressKarlsruhe.geoLocation.size() == 3 - bestMatchAddressKarlsruhe.geoLocation.keySet().containsAll("latitude", "longitude", "type") - - and: "resulting address is Trier (from nominatim)" - bestMatchAddressKarlsruhe.hashKey == null - bestMatchAddressKarlsruhe.city == "Trier" - bestMatchAddressKarlsruhe.geoLocation.type == "GEOLOCATION" - bestMatchAddressKarlsruhe.countryCode == "de" - - } - - def "request for addresses which does not exist "() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - and: "address details city, postal code" - def urlParams = [ - "city": "adfac", - "postalcode": "1", - "countrycode": "DE" - ] - - when: "addresses by city and postal code are requested" - def response - try { - client.get(path: "/api/addresses/bestmatch", query: urlParams); - } catch (HttpResponseException e) { - response = e.getResponse() - } - - then: "result status is 404 NOT FOUND" - response.status == 404 - - } -} diff --git a/iris-api-tests/src/test/groovy/address/AddressByGeolocationSpec.groovy b/iris-api-tests/src/test/groovy/address/AddressByGeolocationSpec.groovy deleted file mode 100644 index 360f3a35..00000000 --- a/iris-api-tests/src/test/groovy/address/AddressByGeolocationSpec.groovy +++ /dev/null @@ -1,39 +0,0 @@ -package address - -import spock.lang.Specification -import util.ClientFactory - -class AddressByGeolocationSpec extends Specification { - - def "request for geolocation"() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - when: "geolocation with latitude 49.123 and longituide 8.12 is requested" - def response = client.get(path: "/api/reversegeocode/49.123:8.12/") - def address = response.data.reverseGeocodeResponse.address - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "the address should have certain attributes" - def addressAttributes = address.keySet() - addressAttributes.size() == 10 - addressAttributes.containsAll("niceName", "address", "placeId", "countryCode", "osmId", "longitude", "latitude", - "type", "shortName", "displayName"); - - and: "the address is of type ADDRESS" - address.type == "ADDRESS" - - and: "the address has the requested longitude and latitude" - address.latitude == 49.123 - address.longitude == 8.12 - - and: "the address's actual address has certain attributes" - address.address.keySet().size() == 7 - println address.address.keySet() - address.address.keySet().containsAll("country", "country_code", "road", "county", "postcode", - "state", "village") - } -} diff --git a/iris-api-tests/src/test/groovy/address/AddressByOsmIdSpec.groovy b/iris-api-tests/src/test/groovy/address/AddressByOsmIdSpec.groovy deleted file mode 100644 index 6c370481..00000000 --- a/iris-api-tests/src/test/groovy/address/AddressByOsmIdSpec.groovy +++ /dev/null @@ -1,49 +0,0 @@ -package address - -import spock.lang.Specification -import util.ClientFactory - -class AddressByOsmIdSpec extends Specification { - - def "request for addresses with osm id "() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - when: "address with osm id 90085697 is requested" - def response = client.get(path: "/api/osmaddresses/90085697") - def addresses = response.data.geoCodeResponse.addresses.addresses - def parentAddress = response.data.geoCodeResponse.addresses.parentAddress - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "there should be a parent address" - parentAddress.size() == 1 - - and: "that parent address should have certain attributes" - def parentAddressAttributes = parentAddress.get(0).keySet() - parentAddressAttributes.size() == 10 - parentAddressAttributes.containsAll("niceName", "address", "placeId", "countryCode", "osmId", "longitude", - "latitude", "type", "shortName", "displayName") - - and: "there should be exactly one address in the response" - def innerAddresses = addresses.get(0) - innerAddresses.size() == 1 - - and: "that address should have certain attributes" - def address = innerAddresses.get(0) - def addressAttributes = address.keySet() - addressAttributes.size() == 10 - addressAttributes.containsAll("address", "displayName", "countryCode", "osmId", "latitude", "placeId", - "niceName", "shortName", "type", "longitude"); - - and: "that address has the requested osmid" - address.osmId == 90085697 - - and: "that address's actual address has certain attributes" - address["address"].keySet().size() == 9 - address["address"].keySet().containsAll("country", "country_code", "road", "city", "state_district", - "postcode", "suburb", "house_number", "state") - } -} diff --git a/iris-api-tests/src/test/groovy/address/AddressWherePlaceIsInSpec.groovy b/iris-api-tests/src/test/groovy/address/AddressWherePlaceIsInSpec.groovy deleted file mode 100644 index 5aa1721b..00000000 --- a/iris-api-tests/src/test/groovy/address/AddressWherePlaceIsInSpec.groovy +++ /dev/null @@ -1,34 +0,0 @@ -package address - -import spock.lang.Specification -import util.ClientFactory - -class AddressWherePlaceIsInSpec extends Specification { - - def "request for addresses containing place"() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - when: "addresses with place id 50350574 are requested" - def response = client.get(path: "/api/places/50350574/addresses") - def addresses = response.data.addresses - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "there should be fifteen addresses in the response" - addresses.size() == 15 - - and: "an address should have certain attributes" - def address = addresses.get(0) - def addressAttributes = address.keySet() - addressAttributes.size() == 10 - addressAttributes.containsAll("niceName", "address", "placeId", "countryCode", "osmId", "longitude", "latitude", - "type", "shortName", "displayName"); - - and: "that address has the requested placeid" - address.placeId == 50350574 - - } -} \ No newline at end of file diff --git a/iris-api-tests/src/test/groovy/address/staticsearch/StaticAddressByBoundingBoxSpec.groovy b/iris-api-tests/src/test/groovy/address/staticsearch/StaticAddressByBoundingBoxSpec.groovy deleted file mode 100644 index 09a31413..00000000 --- a/iris-api-tests/src/test/groovy/address/staticsearch/StaticAddressByBoundingBoxSpec.groovy +++ /dev/null @@ -1,34 +0,0 @@ -package address.staticsearch - -import spock.lang.Specification -import util.ClientFactory - -/** - * @author Sandra Thieme - thieme@synyx.de - * @author David Schilling - schilling@synyx.de - * @author Oliver Messner - messner@synyx.de - */ -class StaticAddressByBoundingBoxSpec extends Specification { - - def "request for static addresses within a bounding box"() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - and: "a bounding box definition" - def urlParams = ["lat": "49.0126538640", "lon": "8.3770751953", "distance": "10"] - - when: "request static addresses within bounding box" - def response = client.get(path: "/api/staticaddresses", query: urlParams) - - then: "response status code should be 200 (OK)" - with(response) { - status == 200 - - data.first().keySet() == ['uniqueId', 'geoLocation', 'country', 'postalcode', - 'city', 'suburb', 'hashKey'] as Set - - data.first().geoLocation.keySet() == ['latitude', 'longitude', 'type'] as Set - } - } -} \ No newline at end of file diff --git a/iris-api-tests/src/test/groovy/address/staticsearch/StaticAddressByGeolocationSpec.groovy b/iris-api-tests/src/test/groovy/address/staticsearch/StaticAddressByGeolocationSpec.groovy deleted file mode 100644 index 6d89c634..00000000 --- a/iris-api-tests/src/test/groovy/address/staticsearch/StaticAddressByGeolocationSpec.groovy +++ /dev/null @@ -1,57 +0,0 @@ -package address.staticsearch - -import spock.lang.Specification -import util.ClientFactory - -/** - * @author Arnold Franke - franke@synyx.de - */ -class StaticAddressByGeolocationSpec extends Specification{ - - def "request for Static Addresses matching the given coordinates"() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - and: "a geolocation (latitude, longitude)" - def urlParams = [ - "lat": "49.0126538640", - "lon": "8.3770751953" - ] - - when: "static addresses are requested" - def response = client.get(path: "/api/staticaddresses", query: urlParams) - print(response.data) - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "response consists of a list of one addresslist object" - def addressListList = response.data.geoCodeResponse.addresses - addressListList.size() == 1 - - and: "the addresslistobject contains a parent address and a list of static addresses" - def addressListObject = addressListList[0] - def parentAddress = addressListObject.parentAddress - def staticaddresses = addressListObject.addresses - staticaddresses.size() == 1 - - and: "the parent address object has certain attributes" - parentAddress.size() == 10 - parentAddress.keySet().containsAll("countryCode", "niceName", "displayName", "osmId", "placeId", "shortName", "address", "type", "longitude", "latitude") - parentAddress.type == "ADDRESS" - - and: "a static address contains certain attributes" - def staticaddress = staticaddresses[0] - staticaddress.size() == 10 - staticaddress.keySet().containsAll("countryCode", "niceName", "displayName", "osmId", "placeId", "shortName", "address", "type", "longitude", "latitude") - - and: "the type of a static address is ADDRESS" - staticaddress.type == "ADDRESS" - - and: "a static address contains a address map with certain attributes" - def addressmap = staticaddress.address - addressmap.size() == 6 - addressmap.keySet().containsAll("suburb", "static_id", "postcode", "country_code", "city", "hashkey") - } -} \ No newline at end of file diff --git a/iris-api-tests/src/test/groovy/address/staticsearch/StaticAddressByPostalCodeAndCityAndCountrySpec.groovy b/iris-api-tests/src/test/groovy/address/staticsearch/StaticAddressByPostalCodeAndCityAndCountrySpec.groovy deleted file mode 100644 index 4a1f3a7d..00000000 --- a/iris-api-tests/src/test/groovy/address/staticsearch/StaticAddressByPostalCodeAndCityAndCountrySpec.groovy +++ /dev/null @@ -1,47 +0,0 @@ -package address.staticsearch - -import spock.lang.Specification -import util.ClientFactory - -/** - * @author Arnold Franke - franke@synyx.de - */ -class StaticAddressByPostalCodeAndCityAndCountrySpec extends Specification { - - def "request for Static Addresses matching the given details"() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - and: "address details (postalCode, city, country)" - def urlParams = [ - "postalCode": "76131", - "city": "Karlsruhe", - "country": "DE" - ] - - when: "static addresses are requested" - def response = client.get(path: "/api/staticaddresses", query: urlParams) - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "response consists of one address" - def staticAddresses = response.responseData - staticAddresses.size() == 1 - - and: "a static address contains certain attributes" - def staticaddress = staticAddresses[0] - staticaddress.keySet().size() == 10 - staticaddress.keySet().containsAll("countryCode", "niceName", "displayName", "osmId", "placeId", "shortName", "address", "type", "longitude", "latitude") - - and: "a static address contains a address map with certain attributes" - def addressmap = staticaddress.address - addressmap.size() == 6 - addressmap.keySet().containsAll("suburb", "static_id", "postcode", "country_code", "city", "hashkey") - - and: "the type of a static address is ADDRESS" - staticaddress.type == "ADDRESS" - - } -} diff --git a/iris-api-tests/src/test/groovy/authorization/AuthorizationSpec.groovy b/iris-api-tests/src/test/groovy/authorization/AuthorizationSpec.groovy deleted file mode 100644 index 73740d7a..00000000 --- a/iris-api-tests/src/test/groovy/authorization/AuthorizationSpec.groovy +++ /dev/null @@ -1,101 +0,0 @@ -package authorization - -import groovyx.net.http.ContentType -import groovyx.net.http.HttpResponseException -import spock.lang.Specification -import util.ClientFactory - -class AuthorizationSpec extends Specification { - - def "request for api from non-authorized user"() { - - given: "a REST client without login credentials" - def client = ClientFactory.newUnauthorizedClient() - - when: "api is requested" - client.get(path: "/api/") - - then: "the request fails" - def e = thrown(HttpResponseException) - def response = e.getResponse(); - - then: "response status code should be 401 (Unauthorized)" - response.status == 401 - - and: "response should have correct authentication header" - response.getFirstHeader("WWW-Authenticate").getValue() == "Basic realm=\"IRIS API\"" - } - - def "request for seaport synchronisation for non allowed user"() { - - given: "a REST client with user login credentials" - def client = ClientFactory.newUserClient() - - when: "seaport creation is requested" - def seaportUid = System.nanoTime() - def content = [ - name: "seaport-${seaportUid}".toString(), - longitude: "8.${seaportUid}".toString(), - latitude: "49.${seaportUid}".toString() - ] - client.put(path: "/api/seaports/$seaportUid", body: content, contentType: ContentType.JSON) - - then: "the request fails" - def e = thrown(HttpResponseException) - - then: "response status code should be 403 (Forbidden)" - e.getResponse().status == 403 - } - - def "request for terminal synchronisation for non allowed user"() { - - given: "a REST client with user login credentials" - def client = ClientFactory.newUserClient() - - when: "terminal creation is requested" - def terminalUid = System.nanoTime() - def content = [ - name: "terminal-${terminalUid}".toString(), - longitude: "8.${terminalUid}".toString(), - latitude: "49.${terminalUid}".toString(), - region: "NOT_SET" - ] - client.put(path: "/api/terminals/$terminalUid", body: content, contentType: ContentType.JSON) - - then: "the request fails" - def e = thrown(HttpResponseException) - - then: "response status code should be 403 (Forbidden)" - e.getResponse().status == 403 - } - - def "request for routerevision creation"() { - - given: "a REST client with user login credentials" - def client = ClientFactory.newUserClient() - - when: "routerevision creation is requested" - client.post(path: "/api/routerevisions", contentType: ContentType.JSON) - - then: "the request fails" - def e = thrown(HttpResponseException) - - then: "response status code should be 403 (Forbidden)" - e.getResponse().status == 403 - } - - def "request for connection creation"() { - - given: "a REST client with user login credentials" - def client = ClientFactory.newUserClient() - - when: "connection creation is requested" - client.post(path: "/api/connections", contentType: ContentType.JSON) - - then: "the request fails" - def e = thrown(HttpResponseException) - - then: "response status code should be 403 (Forbidden)" - e.getResponse().status == 403 - } -} diff --git a/iris-api-tests/src/test/groovy/connection/ConnectionSpec.groovy b/iris-api-tests/src/test/groovy/connection/ConnectionSpec.groovy deleted file mode 100644 index 8c315afa..00000000 --- a/iris-api-tests/src/test/groovy/connection/ConnectionSpec.groovy +++ /dev/null @@ -1,25 +0,0 @@ -package connection - -import spock.lang.Specification -import util.ClientFactory - -class ConnectionSpec extends Specification { - - def "request for connections"() { - - given: "a REST client" - def client = new ClientFactory().newAdminClient() - - when: "connections for a specified terminal are requested" - def response = client.get(path: '/api/connections', query: [terminalUid: '1301000000000001']) - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "response body is as expected" - response.data[0].keySet() == ['routeType', 'terminalUid', 'seaportUid'] as Set - response.data[0].terminalUid == '1301000000000001' - response.data[0].seaportUid == '1301000000000002' - response.data[0].routeType == 'BARGE' - } -} \ No newline at end of file diff --git a/iris-api-tests/src/test/groovy/connection/ConnectionsForTerminalSpec.groovy b/iris-api-tests/src/test/groovy/connection/ConnectionsForTerminalSpec.groovy deleted file mode 100644 index d7641b53..00000000 --- a/iris-api-tests/src/test/groovy/connection/ConnectionsForTerminalSpec.groovy +++ /dev/null @@ -1,36 +0,0 @@ -package connection - -import spock.lang.Specification -import util.ClientFactory - -class ConnectionsForTerminalSpec extends Specification { - - def "request for Connections belonging to specific Terminal"() { - given: "a REST client" - def client = ClientFactory.newAdminClient() - - and: "a Terminal Unique ID" - def urlParams = ["terminalUid": 1301000000000001] - - when: "connections are requested" - def response = client.get(path: "/api/connections", query: urlParams) - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "response consists at least one connection" - response.responseData.size() >= 1 - - and: "a connection contains certain attributes" - def connection = response.responseData[0] - connection.keySet().size() == 3 - connection.keySet().containsAll("seaportUid", "terminalUid", "routeType") - connection.terminalUid == "1301000000000001" - - and: "the attributes have certain types" - connection.seaportUid.isNumber() - connection.terminalUid.isNumber() - !connection.routeType.isNumber() - - } -} diff --git a/iris-api-tests/src/test/groovy/connection/EnrichedRouteSpec.groovy b/iris-api-tests/src/test/groovy/connection/EnrichedRouteSpec.groovy deleted file mode 100644 index 8caf4f4d..00000000 --- a/iris-api-tests/src/test/groovy/connection/EnrichedRouteSpec.groovy +++ /dev/null @@ -1,64 +0,0 @@ -package connection - -import spock.lang.Specification -import util.ClientFactory - -class EnrichedRouteSpec extends Specification { - - def "request for enriched route"() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - and: "a route specification" - def routeParams = [ - "data.parts[0].origin.longitude" : 8.544177, - "data.parts[0].origin.latitude" : 50.08162, - "data.parts[0].destination.longitude": 8.4232, - "data.parts[0].destination.latitude" : 49.01179, - "data.parts[0].routeType" : "TRUCK", - "data.parts[0].containerType" : "FORTY", - "data.parts[0].containerState" : "EMPTY", - "data.parts[1].origin.longitude" : 8.4232, - "data.parts[1].origin.latitude" : 49.01179, - "data.parts[1].destination.longitude": 8.544177, - "data.parts[1].destination.latitude" : 50.08162, - "data.parts[1].routeType" : "TRUCK", - "data.parts[1].containerType" : "FORTY", - "data.parts[1].containerState" : "FULL", - "data.parts[2].origin.longitude" : 8.544177, - "data.parts[2].origin.latitude" : 50.08162, - "data.parts[2].destination.longitude": 4.3, - "data.parts[2].destination.latitude" : 51.36833, - "data.parts[2].routeType" : "BARGE", - "data.parts[2].containerType" : "FORTY", - "data.parts[2].containerState" : "FULL", - ] - - when: "details are requested" - def response = client.get(path: "/api/routedetails", query: routeParams) - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "the route has certain attributes" - def route = response.data.response.route - route.keySet().size() == 9 - route.keySet().containsAll("product", "errors", "responsibleTerminal", "direction", "name", "roundTrip", "data", "shortName", "url") - - and: "the route's data has certain attribures" - route.data.keySet().size() == 8 - route.data.keySet().containsAll("co2", "parts", "totalRealTollDistance", "totalDuration", "totalDistance", - "totalTollDistance", "co2DirectTruck", "totalOnewayTruckDistance") - - and: "each route part has certain attributes" - route.data.parts.each { - assert it.keySet().size() == 9 - assert it.keySet().containsAll("containerType", "routeType", "direction", "name", "containerState", "origin", - "data", "destination", "subRouteParts") - assert it.data.keySet().size() == 9 - assert it.data.keySet().containsAll("electricDistance", "duration", "distance", "railDieselDistance", - "bargeDieselDistance", "co2", "dieselDistance", "tollDistance", "airlineDistance") - } - } -} \ No newline at end of file diff --git a/iris-api-tests/src/test/groovy/connection/SeaportRouteSpec.groovy b/iris-api-tests/src/test/groovy/connection/SeaportRouteSpec.groovy deleted file mode 100644 index dd5a4c97..00000000 --- a/iris-api-tests/src/test/groovy/connection/SeaportRouteSpec.groovy +++ /dev/null @@ -1,45 +0,0 @@ -package connection - -import spock.lang.Specification -import util.ClientFactory - -class SeaportRouteSpec extends Specification { - - def "request for seaport routes"() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - when: "routes for a specified seaport are requested" - def requestUrl = String.format('/api/connections/%s/%s:%s/%s', 1301000000000002, 49.01179, 8.4232, false) - def params = [containerType: "TWENTY_LIGHT", isImport: false, combo: "WATERWAY"] - def response = client.get(path: requestUrl, query: params) - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "there should be at least one route" - def routes = response.data.response.routes - !routes.isEmpty() - - routes.each { - and: "each route has certain fields" - def routeAttributes = it.keySet() - assert routeAttributes.size() == 9 - assert routeAttributes.containsAll("roundTrip", "product", "shortName", "name", "data", "errors", "direction", "url", "responsibleTerminal") - - and: "each route's data field has certain fields" - def data = it.data - def dataAttributes = data.keySet() - assert dataAttributes.size() == 8 - assert dataAttributes.containsAll("co2", "co2DirectTruck", "totalDistance", "totalOnewayTruckDistance", - "totalRealTollDistance", "totalTollDistance", "totalDuration", "parts") - - and: "the route parts have certain fields" - def partAttributes = data.parts.first().keySet() - assert partAttributes.size() == 9 - assert partAttributes.containsAll("name", "data", "origin", "containerState", "containerType", "direction", - "routeType", "destination", "subRouteParts") - } - } -} \ No newline at end of file diff --git a/iris-api-tests/src/test/groovy/connection/SeaportsInConnectionsSpec.groovy b/iris-api-tests/src/test/groovy/connection/SeaportsInConnectionsSpec.groovy deleted file mode 100644 index bc4066c0..00000000 --- a/iris-api-tests/src/test/groovy/connection/SeaportsInConnectionsSpec.groovy +++ /dev/null @@ -1,49 +0,0 @@ -package connection - -import spock.lang.* -import util.ClientFactory -import org.apache.http.client.HttpResponseException - -/** - * @author Oliver Messner - messner@synyx.de - */ -class SeaportsInConnectionsSpec extends Specification { - - def "request for connected seaport"() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - when: "request is sent to server" - def response = client.get(path: "/api/connections/seaports") - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "the seaport object has certain attributes" - def seaports = response.data.seaports - !seaports.isEmpty() - seaports.each { - assert it.keySet().size() == 6 - assert it.keySet().containsAll("latitude", "longitude", "name", "enabled", "type", "uniqueId") - } - - and: "links are provided" - def links = response.data.links - !links.isEmpty() - } - - def "request for undefined combo type"() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - when: "an invalid combotype is requested" - client.get(path: "/api/connections/seaports", query: [combo: 'INVALID COMBO TYPE']) - - then: "response status type is bad request" - def e = thrown(HttpResponseException) - e.message == 'Bad Request' - e.statusCode == 400 - } -} \ No newline at end of file diff --git a/iris-api-tests/src/test/groovy/connection/TerminalsConnectedToSeaportSpec.groovy b/iris-api-tests/src/test/groovy/connection/TerminalsConnectedToSeaportSpec.groovy deleted file mode 100644 index 7b689dea..00000000 --- a/iris-api-tests/src/test/groovy/connection/TerminalsConnectedToSeaportSpec.groovy +++ /dev/null @@ -1,34 +0,0 @@ -package connection - -import spock.lang.Specification -import util.ClientFactory - -class TerminalsConnectedToSeaportSpec extends Specification { - - def "request for terminals connected to a seaport with route type BARGE"() { - given: "a REST client" - def client = ClientFactory.newAdminClient() - - and: "a seaport unique ID and a route type" - def urlParams = [ - "seaportUid": 1301000000000002, - "routeType": "BARGE" - ] - - when: "terminals for this combination are requested" - def response = client.get(path: "/api/terminals", query: urlParams) - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "the response contains terminals" - def terminals = response.data.response.terminals - !terminals.isEmpty() - - and: "the terminals contains certain attributes" - terminals.each { - assert it.keySet().size() == 7 - assert it.keySet().containsAll("latitude", "longitude", "name", "enabled", "uniqueId", "type", "region") - } - } -} diff --git a/iris-api-tests/src/test/groovy/countries/CountriesSpec.groovy b/iris-api-tests/src/test/groovy/countries/CountriesSpec.groovy deleted file mode 100644 index f4fe84f6..00000000 --- a/iris-api-tests/src/test/groovy/countries/CountriesSpec.groovy +++ /dev/null @@ -1,30 +0,0 @@ -package countries - -import spock.lang.Specification -import util.ClientFactory - -class CountriesSpec extends Specification { - - def "request for countries"() { - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - when: "countries are requested" - def response = client.get(path: "/api/countries/") - def countries = response.data.countriesResponse.countries - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "countries amount should be 12" - countries.size() == 12 - - and: "Belgium should be in the list" - countries.contains([name: 'Belgium', value: 'BE']); - - and: "Germany should be in the list" - countries.contains([name: 'Germany', value: 'DE']); - } - -} diff --git a/iris-api-tests/src/test/groovy/distance/AirlineDistanceSpec.groovy b/iris-api-tests/src/test/groovy/distance/AirlineDistanceSpec.groovy deleted file mode 100644 index d1e16eb0..00000000 --- a/iris-api-tests/src/test/groovy/distance/AirlineDistanceSpec.groovy +++ /dev/null @@ -1,35 +0,0 @@ -package distance - -import spock.lang.Specification -import util.ClientFactory - -class AirlineDistanceSpec extends Specification { - - def "request for airline distance between karlsruhe and duisburg"() { - - def latKA = 49.008085 - def lonKA = 8.403756 - - def latDU = 51.435146 - def lonDU = 6.762691 - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - when: "airline distance is requested" - def params = [alat:latKA, alon:lonKA, blat:latDU, blon:lonDU] - def response = client.get(path: "/api/airlineDistance", query: params) - def airlineDistance = response.data.airlineDistance - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "airlineDistance should consist of unit and distance and links" - airlineDistance.keySet().size() == 3 - airlineDistance.keySet().containsAll("unit", "distance", "links") - - and: "unit is meter" - airlineDistance.unit == "meter" - - } -} diff --git a/iris-api-tests/src/test/groovy/routerevision/RouteRevisionSpec.groovy b/iris-api-tests/src/test/groovy/routerevision/RouteRevisionSpec.groovy deleted file mode 100644 index d8180df5..00000000 --- a/iris-api-tests/src/test/groovy/routerevision/RouteRevisionSpec.groovy +++ /dev/null @@ -1,61 +0,0 @@ -package routerevision - -import groovyx.net.http.HttpResponseException -import spock.lang.Specification -import util.ClientFactory - -class RouteRevisionSpec extends Specification { - - def "request for route revision for terminal one"() { - - def latKA = 49.008085 - def lonKA = 8.403756 - - def uid = 1301000000000001 - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - when: "route revision is requested" - def params = [latitude:latKA, longitude:lonKA, terminalUid:uid] - def response = client.get(path: "/api/routerevisions", query: params) - def revision = response.data - - then: "response status code should be 200 (OK)" - response.status == 200 - - and: "revision should consist of certain attributes" - revision.keySet().size() == 11 - revision.keySet().containsAll("tollDistanceOneWayInKilometer", "airlineDistanceInKilometer", "terminalUid", "latitude", - "radiusInMeter", "comment", "id", "truckDistanceOneWayInKilometer", "longitude", "validTo", "validFrom") - - } - - def "request for route revision for terminal one fails"() { - - def latKA = 49.008085 - def lonKA = 8.403756 - - def uid = 47182372189378941 - - given: "a REST client" - def client = ClientFactory.newAdminClient() - - when: "route revision is requested" - def params = [latitude:latKA, longitude:lonKA, terminalUid:uid] - client.get(path: "/api/routerevisions", query: params) - - then: "the request fails" - def e = thrown(HttpResponseException) - def response = e.getResponse(); - def errorResponse = response.data - - then: "response status code should be 200 (OK)" - response.status == 404 - - and: "error object consists of code and message" - errorResponse.keySet().size() == 3 - errorResponse.keySet().containsAll("code", "message", "validationError") - - } -} diff --git a/iris-api-tests/src/test/groovy/seaport/SeaportSpec.groovy b/iris-api-tests/src/test/groovy/seaport/SeaportSpec.groovy deleted file mode 100644 index 8d8a79ef..00000000 --- a/iris-api-tests/src/test/groovy/seaport/SeaportSpec.groovy +++ /dev/null @@ -1,49 +0,0 @@ -package seaport - -import groovyx.net.http.ContentType -import spock.lang.Specification -import util.ClientFactory - -class SeaportSpec extends Specification { - - def 'create new seaport'() { - - given: "a REST client" - def client = new ClientFactory().newAdminClient() - - when: 'new seaport is created' - def seaportUid = System.nanoTime() - def content = [ - name: "seaport-${seaportUid}".toString(), - longitude: "8.${seaportUid}".toString(), - latitude: "49.${seaportUid}".toString() - ] - - def response = client.put(path: "/api/seaports/$seaportUid", body: content, contentType: ContentType.JSON) - - then: 'response status code should be 201 (CREATED)' - response.status == 201 - } - - def 'create and update seaport'() { - - given: "a REST client" - def client = new ClientFactory().newAdminClient() - - and: 'a new seaport' - def seaportUid = System.nanoTime() - def content = [ - name: "seaport-${seaportUid}".toString(), - longitude: "8.${seaportUid}".toString(), - latitude: "49.${seaportUid}".toString() - ] - - client.put(path: "/api/seaports/$seaportUid", body: content, contentType: ContentType.JSON) - - when: 'seaport is updated' - def response = client.put(path: "/api/seaports/$seaportUid", body: content, contentType: ContentType.JSON) - - then: 'response status code should be 204 (NO CONTENT)' - response.status == 204 - } -} diff --git a/iris-api-tests/src/test/groovy/terminal/TerminalSpec.groovy b/iris-api-tests/src/test/groovy/terminal/TerminalSpec.groovy deleted file mode 100644 index 6ec5c115..00000000 --- a/iris-api-tests/src/test/groovy/terminal/TerminalSpec.groovy +++ /dev/null @@ -1,51 +0,0 @@ -package terminal - -import groovyx.net.http.ContentType -import spock.lang.Specification -import util.ClientFactory - -class TerminalSpec extends Specification { - - def 'create new terminal'() { - - given: "a REST client" - def client = new ClientFactory().newAdminClient() - - when: 'new terminal is created' - def terminalUid = System.nanoTime() - def content = [ - name: "terminal-${terminalUid}".toString(), - longitude: "8.${terminalUid}".toString(), - latitude: "49.${terminalUid}".toString(), - region: "NOT_SET" - ] - - def response = client.put(path: "/api/terminals/$terminalUid", body: content, contentType: ContentType.JSON) - - then: 'response status code should be 201 (CREATED)' - response.status == 201 - } - - def 'create and update terminal'() { - - given: "a REST client" - def client = new ClientFactory().newAdminClient() - - and: 'a new terminal' - def terminalUid = System.nanoTime() - def content = [ - name: "terminal-${terminalUid}".toString(), - longitude: "8.${terminalUid}".toString(), - latitude: "49.${terminalUid}".toString(), - region: "NOT_SET" - ] - - client.put(path: "/api/terminals/$terminalUid", body: content, contentType: ContentType.JSON) - - when: 'terminal is updated' - def response = client.put(path: "/api/terminals/$terminalUid", body: content, contentType: ContentType.JSON) - - then: 'response status code should be 204 (NO CONTENT)' - assert response.status == 204 - } -} diff --git a/iris-api-tests/src/test/groovy/util/ClientFactory.groovy b/iris-api-tests/src/test/groovy/util/ClientFactory.groovy deleted file mode 100644 index a52a553e..00000000 --- a/iris-api-tests/src/test/groovy/util/ClientFactory.groovy +++ /dev/null @@ -1,26 +0,0 @@ -package util - -import groovyx.net.http.RESTClient - -class ClientFactory { - - static final ENDPOINT = System.getProperty("endpoint") == null ? "http://localhost:8082" : System.getProperty("endpoint") - - static def newAdminClient() { - def client = newUnauthorizedClient() - - // prepare for preemptive authentication - client.headers['Authorization'] = 'Basic ' + "admin@example.com:admin".getBytes('UTF-8').encodeBase64() - return client - } - - static def newUserClient() { - def client = newUnauthorizedClient() - client.headers['Authorization'] = 'Basic ' + "user@example.com:user".getBytes('UTF-8').encodeBase64() - return client - } - - static def newUnauthorizedClient() { - return new RESTClient(ENDPOINT) - } -} \ No newline at end of file