Upgrade to Pro — share decks privately, control downloads, hide ads and more …

越境のデザイン / border crossing design

nrs
December 06, 2022

越境のデザイン / border crossing design

セッションの概要など詳しくはコチラ→https://developers.gmo.jp/developersday/?access=25345

◆ URL
トークURL: https://youtu.be/0Y7ew4FHdO4
チャンネル登録: https://www.youtube.com/c/narusemi?sub_confirmation=1
Twitter: https://twitter.com/nrslib

nrs

December 06, 2022
Tweet

More Decks by nrs

Other Decks in Programming

Transcript

  1. 7

  2. OK

  3. Id AccountId Status Created Modified ModifiedBy 1 1 201 2021/11/2

    12:00:00 2021/11/2 15:00:00 84 2 2 200 2021/11/1 11:00:00 2021/11/2 13:00:00 21 3 3 900 2021/11/1 12:00:00 2021/11/2 13:00:00 50 4 2 105 2021/11/1 12:00:00 2021/11/2 13:00:00 21 5 1 200 2021/11/1 12:00:00 2021/11/2 13:00:00 21 6 2 201 2021/10/30 12:00:00 2021/11/2 14:00:00 84 7 3 201 2021/11/1 12:30:00 2021/11/2 13:00:00 84
  4. Id type entity_key entity_id event_data 1 OrderCreated Order 1 {

    "id" : "xxxxx-order-id-1", "account_id" : "xxxxx-account-id-1", "total" : 200, "order_items" : [{"id" : "xxxxx-item-id-1", "quantity" : 2, "price" : 100 },]} 2 OrderApprovaled Order 1 {} 3 OrderCreated Order 2 {"id" : "xxxxx-order-id-2", "account_id" : "xxxxx-account-id-2","total" : 100, "order_items" : [{"id" : "xxxxx-item-id-1", "quantity" : 1,"price" : 100},]} 4 OrderCanceled Order 2 {} 5 OrderItemActivated Order 1 {} 6 OrderCreated Order 3 {"id" : "xxxxx-order-id-3", "account_id" : "xxxxx-account-id-3","total" : 100, "order_items" : [{"id" : "xxxxx-item-id-1", "quantity" : 1,"price" : 100},]}
  5. Id type entity_key entity_id event_data 1 OrderCreated Order 1 {

    "id" : "xxxxx-order-id-1", "account_id" : "xxxxx-account-id-1", "total" : 200, "order_items" : [{"id" : "xxxxx-item-id-1", "quantity" : 2, "price" : 100 },]} 2 OrderApprovaled Order 1 {} 3 OrderCreated Order 2 {"id" : "xxxxx-order-id-2", "account_id" : "xxxxx-account-id-2","total" : 100, "order_items" : [{"id" : "xxxxx-item-id-1", "quantity" : 1,"price" : 100},]} 4 OrderCanceled Order 2 {} 5 OrderItemActivated Order 1 {} 6 OrderCreated Order 3 {"id" : "xxxxx-order-id-3", "account_id" : "xxxxx-account-id-3","total" : 100, "order_items" : [{"id" : "xxxxx-item-id-1", "quantity" : 1,"price" : 100},]}
  6. Id type entity_key entity_id event_data 1 OrderCreated Order 1 {

    "id" : "xxxxx-order-id-1", "account_id" : "xxxxx-account-id-1", "total" : 200, "order_items" : [{"id" : "xxxxx-item-id-1", "quantity" : 2, "price" : 100 },]} 2 OrderApprovaled Order 1 {} 3 OrderCreated Order 2 {"id" : "xxxxx-order-id-2", "account_id" : "xxxxx-account-id-2","total" : 100, "order_items" : [{"id" : "xxxxx-item-id-1", "quantity" : 1,"price" : 100},]} 4 OrderCanceled Order 2 {} 5 OrderItemActivated Order 1 {} 6 OrderCreated Order 3 {"id" : "xxxxx-order-id-3", "account_id" : "xxxxx-account-id-3","total" : 100, "order_items" : [{"id" : "xxxxx-item-id-1", "quantity" : 1,"price" : 100},]}
  7. @ExtendWith(PactConsumerTestExt::class) class ConsumerTest { ... @Pact(provider = “ProviderService", consumer =

    "ConsumerService") fun getFragment(builder: PactDslWithProvider): RequestResponsePact { return builder .given("Template exists", mapOf("bodyId" to bodyTemplateId)) .uponReceiving("Get template") .pathFromProviderState("/api/templates/¥${id}", "/api/templates/$GetFragmentTemplateId") .method("GET") .willRespondWith() .status(200) .body(PactDslJsonBody().`object`("template") .stringType("templateId", GetFragmentTemplateId) .stringValue("bodyId", bodyTemplateId) .closeObject()).toPact() } @Test @PactTestFor(providerName = "ProviderService", pactMethod = "getFragment") fun get(mockServer: MockServer) { val client = ConsumerClient(mockServer.getUrl()) val getResult = client.getAsMap("/api/templates/$GetFragmentTemplateId", "") val getExpectedResponse = mapOf<String, Map<*,*>>("template" to mapOf( "templateId" to GetFragmentTemplateId, "bodyId" to bodyTemplateId)) Assertions.assertEquals(getResult, getExpectedResponse) } }
  8. @ExtendWith(PactConsumerTestExt::class) class ConsumerTest { ... @Pact(provider = “ProviderService", consumer =

    "ConsumerService") fun getFragment(builder: PactDslWithProvider): RequestResponsePact { return builder .given("Template exists", mapOf("bodyId" to bodyTemplateId)) .uponReceiving("Get template") .pathFromProviderState("/api/templates/¥${id}", "/api/templates/$GetFragmentTemplateId") .method("GET") .willRespondWith() .status(200) .body(PactDslJsonBody().`object`("template") .stringType("templateId", GetFragmentTemplateId) .stringValue("bodyId", bodyTemplateId) .closeObject()).toPact() } @Test @PactTestFor(providerName = "ProviderService", pactMethod = "getFragment") fun get(mockServer: MockServer) { val client = ConsumerClient(mockServer.getUrl()) val getResult = client.getAsMap("/api/templates/$GetFragmentTemplateId", "") val getExpectedResponse = mapOf<String, Map<*,*>>("template" to mapOf( "templateId" to GetFragmentTemplateId, "bodyId" to bodyTemplateId)) Assertions.assertEquals(getResult, getExpectedResponse) } }
  9. @ExtendWith(PactConsumerTestExt::class) class ConsumerTest { ... @Pact(provider = “ProviderService", consumer =

    "ConsumerService") fun getFragment(builder: PactDslWithProvider): RequestResponsePact { return builder .given("Template exists", mapOf("bodyId" to bodyTemplateId)) .uponReceiving("Get template") .pathFromProviderState("/api/templates/¥${id}", "/api/templates/$GetFragmentTemplateId") .method("GET") .willRespondWith() .status(200) .body(PactDslJsonBody().`object`("template") .stringType("templateId", GetFragmentTemplateId) .stringValue("bodyId", bodyTemplateId) .closeObject()).toPact() } @Test @PactTestFor(providerName = "ProviderService", pactMethod = "getFragment") fun get(mockServer: MockServer) { val client = ConsumerClient(mockServer.getUrl()) val getResult = client.getAsMap("/api/templates/$GetFragmentTemplateId", "") val getExpectedResponse = mapOf<String, Map<*,*>>("template" to mapOf( "templateId" to GetFragmentTemplateId, "bodyId" to bodyTemplateId)) Assertions.assertEquals(getResult, getExpectedResponse) } }
  10. @ExtendWith(PactConsumerTestExt::class) class ConsumerTest { ... @Pact(provider = “ProviderService", consumer =

    "ConsumerService") fun getFragment(builder: PactDslWithProvider): RequestResponsePact { return builder .given("Template exists", mapOf("bodyId" to bodyTemplateId)) .uponReceiving("Get template") .pathFromProviderState("/api/templates/¥${id}", "/api/templates/$GetFragmentTemplateId") .method("GET") .willRespondWith() .status(200) .body(PactDslJsonBody().`object`("template") .stringType("templateId", GetFragmentTemplateId) .stringValue("bodyId", bodyTemplateId) .closeObject()).toPact() } @Test @PactTestFor(providerName = "ProviderService", pactMethod = "getFragment") fun get(mockServer: MockServer) { val client = ConsumerClient(mockServer.getUrl()) val getResult = client.getAsMap("/api/templates/$GetFragmentTemplateId", "") val getExpectedResponse = mapOf<String, Map<*,*>>("template" to mapOf( "templateId" to GetFragmentTemplateId, "bodyId" to bodyTemplateId)) Assertions.assertEquals(getResult, getExpectedResponse) } }
  11. @ExtendWith(PactConsumerTestExt::class) class ConsumerTest { ... @Pact(provider = “ProviderService", consumer =

    "ConsumerService") fun getFragment(builder: PactDslWithProvider): RequestResponsePact { return builder .given("Template exists", mapOf("bodyId" to bodyTemplateId)) .uponReceiving("Get template") .pathFromProviderState("/api/templates/¥${id}", "/api/templates/$GetFragmentTemplateId") .method("GET") .willRespondWith() .status(200) .body(PactDslJsonBody().`object`("template") .stringType("templateId", GetFragmentTemplateId) .stringValue("bodyId", bodyTemplateId) .closeObject()).toPact() } @Test @PactTestFor(providerName = "ProviderService", pactMethod = "getFragment") fun get(mockServer: MockServer) { val client = ConsumerClient(mockServer.getUrl()) val getResult = client.getAsMap("/api/templates/$GetFragmentTemplateId", "") val getExpectedResponse = mapOf<String, Map<*,*>>("template" to mapOf( "templateId" to GetFragmentTemplateId, "bodyId" to bodyTemplateId)) Assertions.assertEquals(getResult, getExpectedResponse) } }
  12. @ExtendWith(PactConsumerTestExt::class) class ConsumerTest { ... @Pact(provider = “ProviderService", consumer =

    "ConsumerService") fun getFragment(builder: PactDslWithProvider): RequestResponsePact { return builder .given("Template exists", mapOf("bodyId" to bodyTemplateId)) .uponReceiving("Get template") .pathFromProviderState("/api/templates/¥${id}", "/api/templates/$GetFragmentTemplateId") .method("GET") .willRespondWith() .status(200) .body(PactDslJsonBody().`object`("template") .stringType("templateId", GetFragmentTemplateId) .stringValue("bodyId", bodyTemplateId) .closeObject()).toPact() } @Test @PactTestFor(providerName = "ProviderService", pactMethod = "getFragment") fun get(mockServer: MockServer) { val client = ConsumerClient(mockServer.getUrl()) val getResult = client.getAsMap("/api/templates/$GetFragmentTemplateId", "") val getExpectedResponse = mapOf<String, Map<*,*>>("template" to mapOf( "templateId" to GetFragmentTemplateId, "bodyId" to bodyTemplateId)) Assertions.assertEquals(getResult, getExpectedResponse) } }
  13. @Provider(“ProviderService") @PactFolder("pacts") class ProviderTest { @BeforeEach fun beforeEach(context: PactVerificationContext) {

    context.target = HttpTestTarget.fromUrl(URL("http","localhost", 8180, "/"), ) } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider::class) fun pactVerificationTestTemplate(context: PactVerificationContext) { context.verifyInteraction() } @State("Template exists") fun templateExists(params: Map<String, Any>): Map<String, Any> { val rest = RestTemplate() val request = TemplatePostRequestModel( bodyTemplateId = params["bodyId"] as String ) val response = rest.postForEntity( "http://localhost:8180/api/templates", request, TemplatePostResponseModel::class.java) return mapOf("id" to response.body!!.templateId) } }
  14. @Provider(“ProviderService") @PactFolder("pacts") class ProviderTest { @BeforeEach fun beforeEach(context: PactVerificationContext) {

    context.target = HttpTestTarget.fromUrl(URL("http","localhost", 8180, "/"), ) } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider::class) fun pactVerificationTestTemplate(context: PactVerificationContext) { context.verifyInteraction() } @State("Template exists") fun templateExists(params: Map<String, Any>): Map<String, Any> { val rest = RestTemplate() val request = TemplatePostRequestModel( bodyTemplateId = params["bodyId"] as String ) val response = rest.postForEntity( "http://localhost:8180/api/templates", request, TemplatePostResponseModel::class.java) return mapOf("id" to response.body!!.templateId) } }
  15. @Provider(“ProviderService") @PactFolder("pacts") class ProviderTest { @BeforeEach fun beforeEach(context: PactVerificationContext) {

    context.target = HttpTestTarget.fromUrl(URL("http","localhost", 8180, "/"), ) } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider::class) fun pactVerificationTestTemplate(context: PactVerificationContext) { context.verifyInteraction() } @State("Template exists") fun templateExists(params: Map<String, Any>): Map<String, Any> { val rest = RestTemplate() val request = TemplatePostRequestModel( bodyTemplateId = params["bodyId"] as String ) val response = rest.postForEntity( "http://localhost:8180/api/templates", request, TemplatePostResponseModel::class.java) return mapOf("id" to response.body!!.templateId) } }
  16. @ExtendWith(PactConsumerTestExt::class) class ConsumerTest { ... @Pact(provider = “ProviderService", consumer =

    "ConsumerService") fun getFragment(builder: PactDslWithProvider): RequestResponsePact { return builder .given("Template exists", mapOf("bodyId" to bodyTemplateId)) .uponReceiving("Get template") .pathFromProviderState("/api/templates/¥${id}", "/api/templates/$GetFragmentTemplateId") .method("GET") .willRespondWith() .status(200) .body(PactDslJsonBody().`object`("template") .stringType("templateId", GetFragmentTemplateId) .stringValue("bodyId", bodyTemplateId) .closeObject()).toPact() } @Test @PactTestFor(providerName = "ProviderService", pactMethod = "getFragment") fun get(mockServer: MockServer) { val client = ConsumerClient(mockServer.getUrl()) val getResult = client.getAsMap("/api/templates/$GetFragmentTemplateId", "") val getExpectedResponse = mapOf<String, Map<*,*>>("template" to mapOf( "templateId" to GetFragmentTemplateId, "bodyId" to bodyTemplateId)) Assertions.assertEquals(getResult, getExpectedResponse) } }
  17. @ExtendWith(PactConsumerTestExt::class) class ConsumerTest { ... @Pact(provider = “ProviderService", consumer =

    "ConsumerService") fun getFragment(builder: PactDslWithProvider): RequestResponsePact { return builder .given("Template exists", mapOf("bodyId" to bodyTemplateId)) .uponReceiving("Get template") .pathFromProviderState("/api/templates/¥${id}", "/api/templates/$GetFragmentTemplateId") .method("GET") .willRespondWith() .status(200) .body(PactDslJsonBody().`object`("template") .stringType("templateId", GetFragmentTemplateId) .stringValue("bodyId", bodyTemplateId) .closeObject()).toPact() } @Test @PactTestFor(providerName = "ProviderService", pactMethod = "getFragment") fun get(mockServer: MockServer) { val client = ConsumerClient(mockServer.getUrl()) val getResult = client.getAsMap("/api/templates/$GetFragmentTemplateId", "") val getExpectedResponse = mapOf<String, Map<*,*>>("template" to mapOf( "templateId" to GetFragmentTemplateId, "bodyId" to bodyTemplateId)) Assertions.assertEquals(getResult, getExpectedResponse) } }
  18. @Provider(“ProviderService") @PactFolder("pacts") class ProviderTest { @BeforeEach fun beforeEach(context: PactVerificationContext) {

    context.target = HttpTestTarget.fromUrl(URL("http","localhost", 8180, "/"), ) } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider::class) fun pactVerificationTestTemplate(context: PactVerificationContext) { context.verifyInteraction() } @State("Template exists") fun templateExists(params: Map<String, Any>): Map<String, Any> { val rest = RestTemplate() val request = TemplatePostRequestModel( bodyTemplateId = params["bodyId"] as String ) val response = rest.postForEntity( "http://localhost:8180/api/templates", request, TemplatePostResponseModel::class.java) return mapOf("id" to response.body!!.templateId) } }
  19. @ExtendWith(PactConsumerTestExt::class) class ConsumerTest { ... @Pact(provider = “ProviderService", consumer =

    "ConsumerService") fun getFragment(builder: PactDslWithProvider): RequestResponsePact { return builder .given("Template exists", mapOf("bodyId" to bodyTemplateId)) .uponReceiving("Get template") .pathFromProviderState("/api/templates/¥${id}", "/api/templates/$GetFragmentTemplateId") .method("GET") .willRespondWith() .status(200) .body(PactDslJsonBody().`object`("template") .stringType("templateId", GetFragmentTemplateId) .stringValue("bodyId", bodyTemplateId) .closeObject()).toPact() } @Test @PactTestFor(providerName = "ProviderService", pactMethod = "getFragment") fun get(mockServer: MockServer) { val client = ConsumerClient(mockServer.getUrl()) val getResult = client.getAsMap("/api/templates/$GetFragmentTemplateId", "") val getExpectedResponse = mapOf<String, Map<*,*>>("template" to mapOf( "templateId" to GetFragmentTemplateId, "bodyId" to bodyTemplateId)) Assertions.assertEquals(getResult, getExpectedResponse) } }
  20. @Provider(“ProviderService") @PactFolder("pacts") class ProviderTest { @BeforeEach fun beforeEach(context: PactVerificationContext) {

    context.target = HttpTestTarget.fromUrl(URL("http","localhost", 8180, "/"), ) } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider::class) fun pactVerificationTestTemplate(context: PactVerificationContext) { context.verifyInteraction() } @State("Template exists") fun templateExists(params: Map<String, Any>): Map<String, Any> { val rest = RestTemplate() val request = TemplatePostRequestModel( bodyTemplateId = params["bodyId"] as String ) val response = rest.postForEntity( "http://localhost:8180/api/templates", request, TemplatePostResponseModel::class.java) return mapOf("id" to response.body!!.templateId) } }
  21. B D C E A Pact.json For A Pact.json For

    A Pact.json For A Pact.json For A