Skip to content

Commit

Permalink
remove 'extends AbstractFulfillmentSpec'
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaimaaeROUAI committed Apr 7, 2024
1 parent 68708e9 commit a6b963f
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 82 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/**
* Copyright © 2020, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
**/
package mushop

import io.micronaut.http.client.HttpClient
import io.micronaut.http.client.annotation.Client
import jakarta.inject.Inject

abstract class AbstractFulfillmentControllerSpec extends AbstractFulfillmentSpec {

@Inject
@Client("/fulfillment")
HttpClient httpClient

void 'test Fulfillment Controller'() {
expect:
httpClient.toBlocking().retrieve("/123") == "Order 123 is fulfilled"
}
}
/**
* Copyright © 2020, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
**/
package mushop

import io.micronaut.http.client.HttpClient
import io.micronaut.http.client.annotation.Client
import jakarta.inject.Inject

abstract class AbstractFulfillmentControllerSpec {

@Inject
@Client("/fulfillment")
HttpClient httpClient

void 'test Fulfillment Controller'() {
expect:
httpClient.toBlocking().retrieve("/123") == "Order 123 is fulfilled"
}
}
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
/**
* Copyright © 2020, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
**/
package mushop

import io.micronaut.http.client.HttpClient
import io.micronaut.http.client.annotation.Client
import io.micronaut.nats.annotation.NatsListener
import io.micronaut.nats.annotation.Subject
import jakarta.inject.Inject
import spock.util.concurrent.AsyncConditions

abstract class AbstractFulfillmentListenerSpec extends AbstractFulfillmentSpec {

@Inject
@Client("/fulfillment")
HttpClient httpClient

@Inject
ShipmentListener shipmentListener

@Inject
OrdersPublisher ordersPublisher

void 'test it adds shipment details to order'() {
given:
def asyncCond = new AsyncConditions()
shipmentListener.setAsyncConditions(asyncCond)

when:
ordersPublisher.publishOrder(new OrderUpdate(123, null))

then:
asyncCond.await()
}

@NatsListener
static class ShipmentListener {
AsyncConditions asyncConditions

@Subject("mushop-shipments")
void handleShipment(OrderUpdate orderUpdate) {
assert asyncConditions
asyncConditions.evaluate(() -> {
assert orderUpdate.shipment
})
}
}
}
/**
* Copyright © 2020, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
**/
package mushop

import io.micronaut.http.client.HttpClient
import io.micronaut.http.client.annotation.Client
import io.micronaut.nats.annotation.NatsListener
import io.micronaut.nats.annotation.Subject
import jakarta.inject.Inject
import spock.util.concurrent.AsyncConditions

abstract class AbstractFulfillmentListenerSpec {

@Inject
@Client("/fulfillment")
HttpClient httpClient

@Inject
ShipmentListener shipmentListener

@Inject
OrdersPublisher ordersPublisher

void 'test it adds shipment details to order'() {
given:
def asyncCond = new AsyncConditions()
shipmentListener.setAsyncConditions(asyncCond)

when:
ordersPublisher.publishOrder(new OrderUpdate(123, null))

then:
asyncCond.await()
}

@NatsListener
static class ShipmentListener {
AsyncConditions asyncConditions

@Subject("mushop-shipments")
void handleShipment(OrderUpdate orderUpdate) {
assert asyncConditions
asyncConditions.evaluate(() -> {
assert orderUpdate.shipment
})
}
}
}
22 changes: 11 additions & 11 deletions src/fulfillment/tck/src/main/groovy/mushop/OrdersPublisher.groovy
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package mushop

import io.micronaut.nats.annotation.NatsClient
import io.micronaut.nats.annotation.Subject

@NatsClient
interface OrdersPublisher {

@Subject("mushop-orders")
void publishOrder(OrderUpdate orderUpdate)
}
package mushop

import io.micronaut.nats.annotation.NatsClient
import io.micronaut.nats.annotation.Subject

@NatsClient
interface OrdersPublisher {

@Subject("mushop-orders")
void publishOrder(OrderUpdate orderUpdate)
}

0 comments on commit a6b963f

Please sign in to comment.