diff --git a/src/main/kotlin/io/billie/countries/data/CityRepository.kt b/src/main/kotlin/io/billie/countries/data/CityRepository.kt index 6e314e3..bd9152c 100644 --- a/src/main/kotlin/io/billie/countries/data/CityRepository.kt +++ b/src/main/kotlin/io/billie/countries/data/CityRepository.kt @@ -25,6 +25,16 @@ class CityRepository { ) } + @Transactional(readOnly = true) + fun findByNameAndCountryCode(name: String, countryCode: String): CityResponse { + return jdbcTemplate.query( + "select id, name, country_code from organisations_schema.cities where name = ? and country_code = ?", + cityResponseMapper(), + name, + countryCode + ).firstOrNull() ?: throw UnableToFindCity(name, countryCode) + } + private fun cityResponseMapper() = RowMapper { it: ResultSet, _: Int -> CityResponse( it.getObject("id", UUID::class.java), diff --git a/src/main/kotlin/io/billie/countries/data/UnableToFindCity.kt b/src/main/kotlin/io/billie/countries/data/UnableToFindCity.kt new file mode 100644 index 0000000..ca497eb --- /dev/null +++ b/src/main/kotlin/io/billie/countries/data/UnableToFindCity.kt @@ -0,0 +1,3 @@ +package io.billie.countries.data + +class UnableToFindCity(val name: String, val countryCode: String) : RuntimeException() diff --git a/src/main/kotlin/io/billie/countries/service/CountryService.kt b/src/main/kotlin/io/billie/countries/service/CountryService.kt index 4dd33a5..2bf8582 100644 --- a/src/main/kotlin/io/billie/countries/service/CountryService.kt +++ b/src/main/kotlin/io/billie/countries/service/CountryService.kt @@ -14,4 +14,6 @@ class CountryService(val dbCountry: CountryRepository, val dbCity: CityRepositor } fun findCities(countryCode: String): List = dbCity.findByCountryCode(countryCode) + fun findCity(name: String, countryCode: String): CityResponse = dbCity.findByNameAndCountryCode(name, countryCode) + } diff --git a/src/main/kotlin/io/billie/organisations/data/OrganisationRepository.kt b/src/main/kotlin/io/billie/organisations/data/OrganisationRepository.kt index 8c0026b..6cd74be 100644 --- a/src/main/kotlin/io/billie/organisations/data/OrganisationRepository.kt +++ b/src/main/kotlin/io/billie/organisations/data/OrganisationRepository.kt @@ -1,7 +1,13 @@ package io.billie.organisations.data import io.billie.countries.model.CountryResponse -import io.billie.organisations.viewmodel.* +import io.billie.organisations.viewmodel.Address +import io.billie.organisations.viewmodel.AddressRequest +import io.billie.organisations.viewmodel.ContactDetails +import io.billie.organisations.viewmodel.ContactDetailsRequest +import io.billie.organisations.viewmodel.LegalEntityType +import io.billie.organisations.viewmodel.OrganisationRequest +import io.billie.organisations.viewmodel.OrganisationResponse import org.springframework.beans.factory.annotation.Autowired import org.springframework.jdbc.core.JdbcTemplate import org.springframework.jdbc.core.ResultSetExtractor @@ -12,8 +18,7 @@ import org.springframework.stereotype.Repository import org.springframework.transaction.annotation.Transactional import java.sql.Date import java.sql.ResultSet -import java.util.* - +import java.util.UUID @Repository class OrganisationRepository { @@ -27,12 +32,13 @@ class OrganisationRepository { } @Transactional - fun create(organisation: OrganisationRequest): UUID { + fun create(organisation: OrganisationRequest, addressCityId: UUID): UUID { if(!valuesValid(organisation)) { throw UnableToFindCountry(organisation.countryCode) } - val id: UUID = createContactDetails(organisation.contactDetails) - return createOrganisation(organisation, id) + val contactDetailsId = createContactDetails(organisation.contactDetails) + val addressId = createAddress(organisation.address, addressCityId) + return createOrganisation(organisation, contactDetailsId, addressId) } private fun valuesValid(organisation: OrganisationRequest): Boolean { @@ -47,7 +53,7 @@ class OrganisationRepository { return (reply != null) && (reply > 0) } - private fun createOrganisation(org: OrganisationRequest, contactDetailsId: UUID): UUID { + private fun createOrganisation(org: OrganisationRequest, contactDetailsId: UUID, addressId: UUID): UUID { val keyHolder: KeyHolder = GeneratedKeyHolder() jdbcTemplate.update( { connection -> @@ -59,8 +65,9 @@ class OrganisationRepository { "vat_number, " + "registration_number, " + "legal_entity_type, " + - "contact_details_id" + - ") VALUES (?, ?, ?, ?, ?, ?, ?)", + "contact_details_id," + + "address_id" + + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?)", arrayOf("id") ) ps.setString(1, org.name) @@ -70,6 +77,7 @@ class OrganisationRepository { ps.setString(5, org.registrationNumber) ps.setString(6, org.legalEntityType.toString()) ps.setObject(7, contactDetailsId) + ps.setObject(8, addressId) ps }, keyHolder ) @@ -99,6 +107,33 @@ class OrganisationRepository { return keyHolder.getKeyAs(UUID::class.java)!! } + private fun createAddress(address: AddressRequest, addressCityId: UUID): UUID { + val keyHolder: KeyHolder = GeneratedKeyHolder() + jdbcTemplate.update( + { connection -> + val ps = connection.prepareStatement( + "insert into organisations_schema.addresses " + + "(" + + "city_id, " + + "street, " + + "house_number, " + + "postal_code, " + + "additional_info" + + ") values(?,?,?,?,?)", + arrayOf("id") + ) + ps.setObject(1, addressCityId) + ps.setString(2, address.street) + ps.setString(3, address.houseNumber) + ps.setString(4, address.postalCode) + ps.setString(5, address.additionalInfo) + ps + }, + keyHolder + ) + return keyHolder.getKeyAs(UUID::class.java)!! + } + private fun organisationQuery() = "select " + "o.id as id, " + "o.name as name, " + @@ -112,11 +147,20 @@ class OrganisationRepository { "o.contact_details_id as contact_details_id, " + "cd.phone_number as phone_number, " + "cd.fax as fax, " + - "cd.email as email " + + "cd.email as email, " + + "a.id as address_id, " + + "ct.country_code as address_country_code, " + + "ct.name as address_city, " + + "a.street as address_street, " + + "a.house_number as address_house_number, " + + "a.postal_code as address_postal_code, " + + "a.additional_info as address_additional_info " + "from " + "organisations_schema.organisations o " + "INNER JOIN organisations_schema.contact_details cd on o.contact_details_id::uuid = cd.id::uuid " + - "INNER JOIN organisations_schema.countries c on o.country_code = c.country_code " + "INNER JOIN organisations_schema.countries c on o.country_code = c.country_code " + + "INNER JOIN organisations_schema.addresses a on o.address_id::uuid = a.id::uuid " + + "INNER JOIN organisations_schema.cities ct on a.city_id::uuid = ct.id::uuid" private fun organisationMapper() = RowMapper { it: ResultSet, _: Int -> OrganisationResponse( @@ -127,7 +171,8 @@ class OrganisationRepository { it.getString("vat_number"), it.getString("registration_number"), LegalEntityType.valueOf(it.getString("legal_entity_type")), - mapContactDetails(it) + mapContactDetails(it), + mapAddress(it) ) } @@ -148,4 +193,16 @@ class OrganisationRepository { ) } + private fun mapAddress(it: ResultSet): Address { + return Address( + it.getObject("address_id", UUID::class.java), + it.getString("address_country_code"), + it.getString("address_city"), + it.getString("address_street"), + it.getString("address_house_number"), + it.getString("address_postal_code"), + it.getString("address_additional_info") + ) + } + } diff --git a/src/main/kotlin/io/billie/organisations/service/OrganisationService.kt b/src/main/kotlin/io/billie/organisations/service/OrganisationService.kt index d029521..2e450ab 100644 --- a/src/main/kotlin/io/billie/organisations/service/OrganisationService.kt +++ b/src/main/kotlin/io/billie/organisations/service/OrganisationService.kt @@ -1,5 +1,6 @@ package io.billie.organisations.service +import io.billie.countries.service.CountryService import io.billie.organisations.data.OrganisationRepository import io.billie.organisations.viewmodel.OrganisationRequest import io.billie.organisations.viewmodel.OrganisationResponse @@ -7,12 +8,13 @@ import org.springframework.stereotype.Service import java.util.* @Service -class OrganisationService(val db: OrganisationRepository) { +class OrganisationService(val db: OrganisationRepository, val countryService: CountryService) { fun findOrganisations(): List = db.findOrganisations() fun createOrganisation(organisation: OrganisationRequest): UUID { - return db.create(organisation) + val city = countryService.findCity(organisation.address.city, organisation.address.countryCode) + return db.create(organisation, city.id) } } diff --git a/src/main/kotlin/io/billie/organisations/viewmodel/Address.kt b/src/main/kotlin/io/billie/organisations/viewmodel/Address.kt new file mode 100644 index 0000000..7522de7 --- /dev/null +++ b/src/main/kotlin/io/billie/organisations/viewmodel/Address.kt @@ -0,0 +1,14 @@ +package io.billie.organisations.viewmodel + +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.UUID + +class Address( + val id: UUID, + @JsonProperty("country_code") val countryCode: String, + val city: String, + val street: String, + @JsonProperty("house_number") val houseNumber: String, + @JsonProperty("postal_code") val postalCode: String, + @JsonProperty("additional_info") val additionalInfo: String? +) diff --git a/src/main/kotlin/io/billie/organisations/viewmodel/AddressRequest.kt b/src/main/kotlin/io/billie/organisations/viewmodel/AddressRequest.kt new file mode 100644 index 0000000..5b5c53b --- /dev/null +++ b/src/main/kotlin/io/billie/organisations/viewmodel/AddressRequest.kt @@ -0,0 +1,12 @@ +package io.billie.organisations.viewmodel + +import com.fasterxml.jackson.annotation.JsonProperty + +data class AddressRequest( + @JsonProperty("country_code") val countryCode: String, + val city: String, + val street: String, + @JsonProperty("house_number") val houseNumber: String, + @JsonProperty("postal_code") val postalCode: String, + @JsonProperty("additional_info") val additionalInfo: String? +) diff --git a/src/main/kotlin/io/billie/organisations/viewmodel/OrganisationRequest.kt b/src/main/kotlin/io/billie/organisations/viewmodel/OrganisationRequest.kt index 2e31f21..b7846d2 100644 --- a/src/main/kotlin/io/billie/organisations/viewmodel/OrganisationRequest.kt +++ b/src/main/kotlin/io/billie/organisations/viewmodel/OrganisationRequest.kt @@ -16,4 +16,5 @@ data class OrganisationRequest( @JsonProperty("registration_number") val registrationNumber: String?, @JsonProperty("legal_entity_type") val legalEntityType: LegalEntityType, @JsonProperty("contact_details") val contactDetails: ContactDetailsRequest, + @JsonProperty("address") val address: AddressRequest ) diff --git a/src/main/kotlin/io/billie/organisations/viewmodel/OrganisationResponse.kt b/src/main/kotlin/io/billie/organisations/viewmodel/OrganisationResponse.kt index d0fec75..dcf41ec 100644 --- a/src/main/kotlin/io/billie/organisations/viewmodel/OrganisationResponse.kt +++ b/src/main/kotlin/io/billie/organisations/viewmodel/OrganisationResponse.kt @@ -17,4 +17,5 @@ data class OrganisationResponse( @JsonProperty("registration_number") val registrationNumber: String?, @JsonProperty("legal_entity_type") val legalEntityType: LegalEntityType, @JsonProperty("contact_details") val contactDetails: ContactDetails, + val address: Address ) diff --git a/src/main/resources/db/migration/V9__Add_address.sql b/src/main/resources/db/migration/V9__Add_address.sql new file mode 100644 index 0000000..8c2cd1d --- /dev/null +++ b/src/main/resources/db/migration/V9__Add_address.sql @@ -0,0 +1,12 @@ +CREATE TABLE IF NOT EXISTS organisations_schema.addresses +( + id UUID DEFAULT uuid_generate_v4() PRIMARY KEY, + city_id UUID REFERENCES organisations_schema.cities(id), + street VARCHAR(255) NOT NULL, + house_number VARCHAR(255) NOT NULL, + postal_code VARCHAR(255) NOT NULL, + additional_info VARCHAR(255) NOT NULL +); + +ALTER TABLE organisations_schema.organisations +ADD COLUMN address_id UUID REFERENCES organisations_schema.addresses(id); diff --git a/src/test/kotlin/io/billie/functional/CanStoreAndReadOrganisationTest.kt b/src/test/kotlin/io/billie/functional/CanStoreAndReadOrganisationTest.kt index 2d57630..e5f3f6a 100644 --- a/src/test/kotlin/io/billie/functional/CanStoreAndReadOrganisationTest.kt +++ b/src/test/kotlin/io/billie/functional/CanStoreAndReadOrganisationTest.kt @@ -1,16 +1,30 @@ package io.billie.functional import com.fasterxml.jackson.databind.ObjectMapper +import io.billie.functional.data.Fixtures.bbcAddressFixture import io.billie.functional.data.Fixtures.bbcContactFixture import io.billie.functional.data.Fixtures.bbcFixture +import io.billie.functional.data.Fixtures.orgRequestAddressCityBlank +import io.billie.functional.data.Fixtures.orgRequestAddressCityIsIncorrect +import io.billie.functional.data.Fixtures.orgRequestAddressCountryCodeBlank +import io.billie.functional.data.Fixtures.orgRequestAddressCountryCodeIsIncorrect +import io.billie.functional.data.Fixtures.orgRequestAddressHouseNumberBlank +import io.billie.functional.data.Fixtures.orgRequestAddressNoCity +import io.billie.functional.data.Fixtures.orgRequestAddressNoCountryCode +import io.billie.functional.data.Fixtures.orgRequestAddressNoHouseNumber +import io.billie.functional.data.Fixtures.orgRequestAddressNoPostalCode +import io.billie.functional.data.Fixtures.orgRequestAddressNoStreet +import io.billie.functional.data.Fixtures.orgRequestAddressPostalCodeBlank +import io.billie.functional.data.Fixtures.orgRequestAddressStreetBlank import io.billie.functional.data.Fixtures.orgRequestJson import io.billie.functional.data.Fixtures.orgRequestJsonCountryCodeBlank import io.billie.functional.data.Fixtures.orgRequestJsonCountryCodeIncorrect -import io.billie.functional.data.Fixtures.orgRequestJsonNoName import io.billie.functional.data.Fixtures.orgRequestJsonNameBlank import io.billie.functional.data.Fixtures.orgRequestJsonNoContactDetails import io.billie.functional.data.Fixtures.orgRequestJsonNoCountryCode import io.billie.functional.data.Fixtures.orgRequestJsonNoLegalEntityType +import io.billie.functional.data.Fixtures.orgRequestJsonNoName +import io.billie.functional.data.Fixtures.orgRequestNoAddress import io.billie.organisations.viewmodel.Entity import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.core.IsEqual.equalTo @@ -26,8 +40,7 @@ import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status -import java.util.* - +import java.util.UUID @AutoConfigureMockMvc @SpringBootTest(webEnvironment = DEFINED_PORT) @@ -109,6 +122,109 @@ class CanStoreAndReadOrganisationTest { ) .andExpect(status().isBadRequest) } + @Test + fun cannotStoreOrgWhenNoAddressGiven() { + mockMvc.perform( + post("/organisations").contentType(APPLICATION_JSON).content(orgRequestNoAddress()) + ) + .andExpect(status().isBadRequest) + } + + @Test + fun cannotStoreOrgWhenAddressCountryCodeIsMissing() { + mockMvc.perform( + post("/organisations").contentType(APPLICATION_JSON).content(orgRequestAddressNoCountryCode()) + ) + .andExpect(status().isBadRequest) + } + + @Test + fun cannotStoreOrgWhenAddressCountryCodeIsBlank() { + mockMvc.perform( + post("/organisations").contentType(APPLICATION_JSON).content(orgRequestAddressCountryCodeBlank()) + ) + .andExpect(status().isBadRequest) + } + + @Test + fun cannotStoreOrgWhenAddressCountryCodeIsIncorrect() { + mockMvc.perform( + post("/organisations").contentType(APPLICATION_JSON).content(orgRequestAddressCountryCodeIsIncorrect()) + ) + .andExpect(status().isBadRequest) + } + + @Test + fun cannotStoreOrgWhenAddressCityIsIncorrect() { + mockMvc.perform( + post("/organisations").contentType(APPLICATION_JSON).content(orgRequestAddressCityIsIncorrect()) + ) + .andExpect(status().isBadRequest) + } + + @Test + fun cannotStoreOrgWhenAddressCityIsMissing() { + mockMvc.perform( + post("/organisations").contentType(APPLICATION_JSON).content(orgRequestAddressNoCity()) + ) + .andExpect(status().isBadRequest) + } + + @Test + fun cannotStoreOrgWhenAddressCityIsBlank() { + mockMvc.perform( + post("/organisations").contentType(APPLICATION_JSON).content(orgRequestAddressCityBlank()) + ) + .andExpect(status().isBadRequest) + } + + @Test + fun cannotStoreOrgWhenAddressStreetIsMissing() { + mockMvc.perform( + post("/organisations").contentType(APPLICATION_JSON).content(orgRequestAddressNoStreet()) + ) + .andExpect(status().isBadRequest) + } + + @Test + fun cannotStoreOrgWhenAddressStreetIsBlank() { + mockMvc.perform( + post("/organisations").contentType(APPLICATION_JSON).content(orgRequestAddressStreetBlank()) + ) + .andExpect(status().isBadRequest) + } + + @Test + fun cannotStoreOrgWhenAddressHouseNumberIsMissing() { + mockMvc.perform( + post("/organisations").contentType(APPLICATION_JSON).content(orgRequestAddressNoHouseNumber()) + ) + .andExpect(status().isBadRequest) + } + + @Test + fun cannotStoreOrgWhenAddressHouseNumberIsBlank() { + mockMvc.perform( + post("/organisations").contentType(APPLICATION_JSON).content(orgRequestAddressHouseNumberBlank()) + ) + .andExpect(status().isBadRequest) + } + + @Test + fun cannotStoreOrgWhenAddressPostalCodeIsMissing() { + mockMvc.perform( + post("/organisations").contentType(APPLICATION_JSON).content(orgRequestAddressNoPostalCode()) + ) + .andExpect(status().isBadRequest) + } + + @Test + fun cannotStoreOrgWhenAddressPostalCodeIsBlank() { + mockMvc.perform( + post("/organisations").contentType(APPLICATION_JSON).content(orgRequestAddressPostalCodeBlank()) + ) + .andExpect(status().isBadRequest) + } @Test fun canStoreOrg() { @@ -126,6 +242,10 @@ class CanStoreAndReadOrganisationTest { val contactDetailsId: UUID = UUID.fromString(org["contact_details_id"] as String) val contactDetails: Map = contactDetailsFromDatabase(contactDetailsId) assertDataMatches(contactDetails, bbcContactFixture(contactDetailsId)) + + val addressId: UUID = org["address_id"] as UUID + val address: Map = addressFromDatabase(addressId) + assertDataMatches(address, bbcAddressFixture(addressId)) } fun assertDataMatches(reply: Map, assertions: Map) { @@ -143,4 +263,9 @@ class CanStoreAndReadOrganisationTest { private fun contactDetailsFromDatabase(id: UUID): MutableMap = queryEntityFromDatabase("select * from organisations_schema.contact_details where id = ?", id) + private fun addressFromDatabase(id: UUID): MutableMap = + queryEntityFromDatabase("select a.*, ct.country_code as address_country_code, ct.name as address_city " + + "from organisations_schema.addresses a " + + "INNER JOIN organisations_schema.cities ct on a.city_id::uuid = ct.id::uuid where a.id = ?", id) + } diff --git a/src/test/kotlin/io/billie/functional/data/Fixtures.kt b/src/test/kotlin/io/billie/functional/data/Fixtures.kt index 9954801..e4e8c30 100644 --- a/src/test/kotlin/io/billie/functional/data/Fixtures.kt +++ b/src/test/kotlin/io/billie/functional/data/Fixtures.kt @@ -63,6 +63,294 @@ object Fixtures { "}" } + fun orgRequestNoAddress(): String { + return "{\n" + + " \"name\": \"BBC\",\n" + + " \"date_founded\": \"18/10/1922\",\n" + + " \"country_code\": \"GB\",\n" + + " \"vat_number\": \"333289454\",\n" + + " \"registration_number\": \"3686147\",\n" + + " \"legal_entity_type\": \"NONPROFIT_ORGANIZATION\",\n" + + " \"contact_details\": {\n" + + " \"phone_number\": \"+443700100222\",\n" + + " \"fax\": \"\",\n" + + " \"email\": \"yourquestions@bbc.co.uk\"\n" + + " }\n" + + "}" + } + + fun orgRequestAddressCountryCodeBlank(): String { + return "{\n" + + " \"name\": \"BBC\",\n" + + " \"date_founded\": \"18/10/1922\",\n" + + " \"country_code\": \"GB\",\n" + + " \"vat_number\": \"333289454\",\n" + + " \"registration_number\": \"3686147\",\n" + + " \"legal_entity_type\": \"NONPROFIT_ORGANIZATION\",\n" + + " \"contact_details\": {\n" + + " \"phone_number\": \"+443700100222\",\n" + + " \"fax\": \"\",\n" + + " \"email\": \"yourquestions@bbc.co.uk\"\n" + + " },\n" + + " \"address\": {\n" + + " \"country_code\": \"\",\n" + + " \"city\": \"Lake City\",\n" + + " \"street\": \"NE Leon St\",\n" + + " \"house_number\": \"156\",\n" + + " \"postal_code\": \"FL 32055\",\n" + + " }\n" + + "}" + } + + fun orgRequestAddressNoCountryCode(): String { + return "{\n" + + " \"name\": \"BBC\",\n" + + " \"date_founded\": \"18/10/1922\",\n" + + " \"country_code\": \"GB\",\n" + + " \"vat_number\": \"333289454\",\n" + + " \"registration_number\": \"3686147\",\n" + + " \"legal_entity_type\": \"NONPROFIT_ORGANIZATION\",\n" + + " \"contact_details\": {\n" + + " \"phone_number\": \"+443700100222\",\n" + + " \"fax\": \"\",\n" + + " \"email\": \"yourquestions@bbc.co.uk\"\n" + + " },\n" + + " \"address\": {\n" + + " \"city\": \"Lake City\",\n" + + " \"street\": \"NE Leon St\",\n" + + " \"house_number\": \"156\",\n" + + " \"postal_code\": \"FL 32055\",\n" + + " }\n" + + "}" + } + + fun orgRequestAddressCountryCodeIsIncorrect(): String { + return "{\n" + + " \"name\": \"BBC\",\n" + + " \"date_founded\": \"18/10/1922\",\n" + + " \"country_code\": \"GB\",\n" + + " \"vat_number\": \"333289454\",\n" + + " \"registration_number\": \"3686147\",\n" + + " \"legal_entity_type\": \"NONPROFIT_ORGANIZATION\",\n" + + " \"contact_details\": {\n" + + " \"phone_number\": \"+443700100222\",\n" + + " \"fax\": \"\",\n" + + " \"email\": \"yourquestions@bbc.co.uk\"\n" + + " },\n" + + " \"address\": {\n" + + " \"country_code\": \"US123\",\n" + + " \"city\": \"Lake City\",\n" + + " \"street\": \"NE Leon St\",\n" + + " \"house_number\": \"156\",\n" + + " \"postal_code\": \"FL 32055\",\n" + + " }\n" + + "}" + } + + fun orgRequestAddressCityBlank(): String { + return "{\n" + + " \"name\": \"BBC\",\n" + + " \"date_founded\": \"18/10/1922\",\n" + + " \"country_code\": \"GB\",\n" + + " \"vat_number\": \"333289454\",\n" + + " \"registration_number\": \"3686147\",\n" + + " \"legal_entity_type\": \"NONPROFIT_ORGANIZATION\",\n" + + " \"contact_details\": {\n" + + " \"phone_number\": \"+443700100222\",\n" + + " \"fax\": \"\",\n" + + " \"email\": \"yourquestions@bbc.co.uk\"\n" + + " },\n" + + " \"address\": {\n" + + " \"country_code\": \"US\",\n" + + " \"city\": \"\",\n" + + " \"street\": \"NE Leon St\",\n" + + " \"house_number\": \"156\",\n" + + " \"postal_code\": \"FL 32055\",\n" + + " }\n" + + "}" + } + + fun orgRequestAddressNoCity(): String { + return "{\n" + + " \"name\": \"BBC\",\n" + + " \"date_founded\": \"18/10/1922\",\n" + + " \"country_code\": \"GB\",\n" + + " \"vat_number\": \"333289454\",\n" + + " \"registration_number\": \"3686147\",\n" + + " \"legal_entity_type\": \"NONPROFIT_ORGANIZATION\",\n" + + " \"contact_details\": {\n" + + " \"phone_number\": \"+443700100222\",\n" + + " \"fax\": \"\",\n" + + " \"email\": \"yourquestions@bbc.co.uk\"\n" + + " },\n" + + " \"address\": {\n" + + " \"country_code\": \"US\",\n" + + " \"street\": \"NE Leon St\",\n" + + " \"house_number\": \"156\",\n" + + " \"postal_code\": \"FL 32055\",\n" + + " }\n" + + "}" + } + + fun orgRequestAddressCityIsIncorrect(): String { + return "{\n" + + " \"name\": \"BBC\",\n" + + " \"date_founded\": \"18/10/1922\",\n" + + " \"country_code\": \"GB\",\n" + + " \"vat_number\": \"333289454\",\n" + + " \"registration_number\": \"3686147\",\n" + + " \"legal_entity_type\": \"NONPROFIT_ORGANIZATION\",\n" + + " \"contact_details\": {\n" + + " \"phone_number\": \"+443700100222\",\n" + + " \"fax\": \"\",\n" + + " \"email\": \"yourquestions@bbc.co.uk\"\n" + + " },\n" + + " \"address\": {\n" + + " \"country_code\": \"US\",\n" + + " \"city\": \"Lake City123\",\n" + + " \"street\": \"NE Leon St\",\n" + + " \"house_number\": \"156\",\n" + + " \"postal_code\": \"FL 32055\",\n" + + " }\n" + + "}" + } + + fun orgRequestAddressStreetBlank(): String { + return "{\n" + + " \"name\": \"BBC\",\n" + + " \"date_founded\": \"18/10/1922\",\n" + + " \"country_code\": \"GB\",\n" + + " \"vat_number\": \"333289454\",\n" + + " \"registration_number\": \"3686147\",\n" + + " \"legal_entity_type\": \"NONPROFIT_ORGANIZATION\",\n" + + " \"contact_details\": {\n" + + " \"phone_number\": \"+443700100222\",\n" + + " \"fax\": \"\",\n" + + " \"email\": \"yourquestions@bbc.co.uk\"\n" + + " },\n" + + " \"address\": {\n" + + " \"country_code\": \"US\",\n" + + " \"city\": \"Lake City123\",\n" + + " \"street\": \"\",\n" + + " \"house_number\": \"156\",\n" + + " \"postal_code\": \"FL 32055\",\n" + + " }\n" + + "}" + } + + fun orgRequestAddressNoStreet(): String { + return "{\n" + + " \"name\": \"BBC\",\n" + + " \"date_founded\": \"18/10/1922\",\n" + + " \"country_code\": \"GB\",\n" + + " \"vat_number\": \"333289454\",\n" + + " \"registration_number\": \"3686147\",\n" + + " \"legal_entity_type\": \"NONPROFIT_ORGANIZATION\",\n" + + " \"contact_details\": {\n" + + " \"phone_number\": \"+443700100222\",\n" + + " \"fax\": \"\",\n" + + " \"email\": \"yourquestions@bbc.co.uk\"\n" + + " },\n" + + " \"address\": {\n" + + " \"country_code\": \"US\",\n" + + " \"city\": \"Lake City\",\n" + + " \"house_number\": \"156\",\n" + + " \"postal_code\": \"FL 32055\",\n" + + " }\n" + + "}" + } + + fun orgRequestAddressHouseNumberBlank(): String { + return "{\n" + + " \"name\": \"BBC\",\n" + + " \"date_founded\": \"18/10/1922\",\n" + + " \"country_code\": \"GB\",\n" + + " \"vat_number\": \"333289454\",\n" + + " \"registration_number\": \"3686147\",\n" + + " \"legal_entity_type\": \"NONPROFIT_ORGANIZATION\",\n" + + " \"contact_details\": {\n" + + " \"phone_number\": \"+443700100222\",\n" + + " \"fax\": \"\",\n" + + " \"email\": \"yourquestions@bbc.co.uk\"\n" + + " },\n" + + " \"address\": {\n" + + " \"country_code\": \"US\",\n" + + " \"city\": \"Lake City123\",\n" + + " \"street\": \"NE Leon St\",\n" + + " \"house_number\": \"\",\n" + + " \"postal_code\": \"FL 32055\",\n" + + " }\n" + + "}" + } + + fun orgRequestAddressNoHouseNumber(): String { + return "{\n" + + " \"name\": \"BBC\",\n" + + " \"date_founded\": \"18/10/1922\",\n" + + " \"country_code\": \"GB\",\n" + + " \"vat_number\": \"333289454\",\n" + + " \"registration_number\": \"3686147\",\n" + + " \"legal_entity_type\": \"NONPROFIT_ORGANIZATION\",\n" + + " \"contact_details\": {\n" + + " \"phone_number\": \"+443700100222\",\n" + + " \"fax\": \"\",\n" + + " \"email\": \"yourquestions@bbc.co.uk\"\n" + + " },\n" + + " \"address\": {\n" + + " \"country_code\": \"US\",\n" + + " \"city\": \"Lake City123\",\n" + + " \"street\": \"NE Leon St\",\n" + + " \"postal_code\": \"FL 32055\",\n" + + " }\n" + + "}" + } + + fun orgRequestAddressPostalCodeBlank(): String { + return "{\n" + + " \"name\": \"BBC\",\n" + + " \"date_founded\": \"18/10/1922\",\n" + + " \"country_code\": \"GB\",\n" + + " \"vat_number\": \"333289454\",\n" + + " \"registration_number\": \"3686147\",\n" + + " \"legal_entity_type\": \"NONPROFIT_ORGANIZATION\",\n" + + " \"contact_details\": {\n" + + " \"phone_number\": \"+443700100222\",\n" + + " \"fax\": \"\",\n" + + " \"email\": \"yourquestions@bbc.co.uk\"\n" + + " },\n" + + " \"address\": {\n" + + " \"country_code\": \"US\",\n" + + " \"city\": \"Lake City123\",\n" + + " \"street\": \"NE Leon St\",\n" + + " \"house_number\": \"156\",\n" + + " \"postal_code\": \"\",\n" + + " }\n" + + "}" + } + + fun orgRequestAddressNoPostalCode(): String { + return "{\n" + + " \"name\": \"BBC\",\n" + + " \"date_founded\": \"18/10/1922\",\n" + + " \"country_code\": \"GB\",\n" + + " \"vat_number\": \"333289454\",\n" + + " \"registration_number\": \"3686147\",\n" + + " \"legal_entity_type\": \"NONPROFIT_ORGANIZATION\",\n" + + " \"contact_details\": {\n" + + " \"phone_number\": \"+443700100222\",\n" + + " \"fax\": \"\",\n" + + " \"email\": \"yourquestions@bbc.co.uk\"\n" + + " },\n" + + " \"address\": {\n" + + " \"country_code\": \"US\",\n" + + " \"city\": \"Lake City123\",\n" + + " \"street\": \"NE Leon St\",\n" + + " \"house_number\": \"156\",\n" + + " }\n" + + "}" + } + + fun orgRequestJson(): String { return "{\n" + " \"name\": \"BBC\",\n" + @@ -75,6 +363,14 @@ object Fixtures { " \"phone_number\": \"+443700100222\",\n" + " \"fax\": \"\",\n" + " \"email\": \"yourquestions@bbc.co.uk\"\n" + + " },\n" + + " \"address\": {\n" + + " \"country_code\": \"US\",\n" + + " \"city\": \"Lake City\",\n" + + " \"street\": \"NE Leon St\",\n" + + " \"house_number\": \"156\",\n" + + " \"postal_code\": \"FL 32055\",\n" + + " \"additional_info\": \"some info\"\n" + " }\n" + "}" } @@ -147,6 +443,15 @@ object Fixtures { return data } - - + fun bbcAddressFixture(id: UUID): Map { + val data = HashMap() + data["id"] = id + data["address_country_code"] = "US" + data["address_city"] = "Lake City" + data["street"] = "NE Leon St" + data["house_number"] = "156" + data["postal_code"] = "FL 32055" + data["additional_info"] = "some info" + return data + } }