use of io.restassured.common.mapper.TypeRef in project quarkus by quarkusio.
the class Utils method callTheEndpoint.
static void callTheEndpoint(String endpoint) {
List<Book> list = get(endpoint).as(new TypeRef<List<Book>>() {
});
Assertions.assertEquals(0, list.size());
Book book1 = new Book().setAuthor("Victor Hugo").setTitle("Les Misérables").setCategories(Arrays.asList("long", "very long")).setDetails(new BookDetail().setRating(3).setSummary("A very long book"));
Response response = RestAssured.given().header("Content-Type", "application/json").body(book1).post(endpoint).andReturn();
Assertions.assertEquals(202, response.statusCode());
Book book2 = new Book().setAuthor("Victor Hugo").setTitle("Notre-Dame de Paris").setCategories(Arrays.asList("long", "quasimodo")).setDetails(new BookDetail().setRating(4).setSummary("quasimodo and esmeralda"));
response = RestAssured.given().header("Content-Type", "application/json").body(book2).post(endpoint).andReturn();
Assertions.assertEquals(202, response.statusCode());
list = get(endpoint).as(new TypeRef<List<Book>>() {
});
Assertions.assertEquals(2, list.size());
Book book3 = new Book().setAuthor("Charles Baudelaire").setTitle("Les fleurs du mal").setCategories(Collections.singletonList("poem")).setDetails(new BookDetail().setRating(2).setSummary("Les Fleurs du mal is a volume of poetry."));
response = RestAssured.given().header("Content-Type", "application/json").body(book3).post(endpoint).andReturn();
Assertions.assertEquals(202, response.statusCode());
list = get(endpoint).as(new TypeRef<List<Book>>() {
});
Assertions.assertEquals(3, list.size());
list = get(endpoint + "/Victor Hugo").as(new TypeRef<List<Book>>() {
});
Assertions.assertEquals(2, list.size());
}
use of io.restassured.common.mapper.TypeRef in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method testGetBridgesToDeploy.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testGetBridgesToDeploy() {
TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME));
List<BridgeDTO> response = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
});
assertThat(response.stream().filter(x -> x.getStatus().equals(ManagedResourceStatus.ACCEPTED)).count()).isEqualTo(1);
BridgeDTO bridge = response.get(0);
assertThat(bridge.getName()).isEqualTo(TestConstants.DEFAULT_BRIDGE_NAME);
assertThat(bridge.getCustomerId()).isEqualTo(TestConstants.DEFAULT_CUSTOMER_ID);
assertThat(bridge.getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
assertThat(bridge.getEndpoint()).isNull();
}
use of io.restassured.common.mapper.TypeRef in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method testNotifyDeployment.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testNotifyDeployment() {
TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME));
List<BridgeDTO> bridgesToDeployOrDelete = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
});
assertThat(bridgesToDeployOrDelete.stream().filter(x -> x.getStatus().equals(ManagedResourceStatus.ACCEPTED)).count()).isEqualTo(1);
BridgeDTO bridge = bridgesToDeployOrDelete.get(0);
bridge.setStatus(ManagedResourceStatus.PROVISIONING);
TestUtils.updateBridge(bridge).then().statusCode(200);
bridgesToDeployOrDelete = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
});
assertThat(bridgesToDeployOrDelete.size()).isZero();
}
use of io.restassured.common.mapper.TypeRef in project quarkus-quickstarts by quarkusio.
the class PriceTest method test.
@Test
public void test() {
// Check we don't have any prices
List<Price> prices = RestAssured.get("/prices/all").as(new TypeRef<List<Price>>() {
});
Assertions.assertTrue(prices.isEmpty());
// Stream the prices
Client client = ClientBuilder.newClient();
WebTarget target = client.target(PRICES_SSE_ENDPOINT);
List<Double> received = new CopyOnWriteArrayList<>();
SseEventSource source = SseEventSource.target(target).build();
source.register(inboundSseEvent -> received.add(Double.valueOf(inboundSseEvent.readData())));
source.open();
// Send the prices
Price p1 = new Price();
p1.value = 1.0;
Price p2 = new Price();
p2.value = 4.0;
Price p3 = new Price();
p3.value = 2.0;
RestAssured.given().header("Content-Type", "application/json").body(p1).post("/").then().statusCode(204);
RestAssured.given().header("Content-Type", "application/json").body(p2).post("/").then().statusCode(204);
RestAssured.given().header("Content-Type", "application/json").body(p3).post("/").then().statusCode(204);
await().atMost(100000, MILLISECONDS).until(() -> received.size() == 3);
source.close();
Assertions.assertTrue(received.contains(p1.value));
Assertions.assertTrue(received.contains(p2.value));
Assertions.assertTrue(received.contains(p3.value));
prices = RestAssured.get("/prices/all").as(new TypeRef<List<Price>>() {
});
Assertions.assertEquals(prices.size(), 3);
}
use of io.restassured.common.mapper.TypeRef in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method testNotifyDeletion.
@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void testNotifyDeletion() {
TestUtils.createBridge(new BridgeRequest(DEFAULT_BRIDGE_NAME));
final List<BridgeDTO> bridgesToDeployOrDelete = new ArrayList<>();
await().atMost(5, SECONDS).untilAsserted(() -> {
bridgesToDeployOrDelete.clear();
bridgesToDeployOrDelete.addAll(TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
}));
assertThat(bridgesToDeployOrDelete.size()).isEqualTo(1);
});
BridgeDTO bridge = bridgesToDeployOrDelete.get(0);
bridge.setStatus(READY);
TestUtils.updateBridge(bridge).then().statusCode(200);
TestUtils.deleteBridge(bridge.getId()).then().statusCode(202);
BridgeResponse bridgeResponse = TestUtils.getBridge(bridge.getId()).as(BridgeResponse.class);
assertThat(bridgeResponse.getStatus()).isEqualTo(DEPROVISION);
bridge.setStatus(DELETED);
TestUtils.updateBridge(bridge).then().statusCode(200);
TestUtils.getBridge(bridge.getId()).then().statusCode(404);
}
Aggregations