Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
surface into a single parameterized suite.
- Add constructor/builder parameters to supply the initial Lua script as a string or as a file path, and optional additional script paths copied into the container data directory (`Tarantool2Container`, `CartridgeClusterContainer`, `VshardClusterContainer`); simplify bundled `server.lua` accordingly.
- Upgrade TQE to v3.5.0.
- Extract `ObjectMapper` to a static field in the test `tdg.Utils` helper to avoid recreating it on every `sendUsers`/`getUsers` call.

### Documentation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@

public abstract class Utils {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

private Utils() {}

public static List<User> sendUsers(List<User> users, TDGContainer<?> container)
throws IOException {
final List<User> result = new ArrayList<>();
final ObjectMapper objectMapper = new ObjectMapper();
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
for (final User user : users) {
final String jsonUser = objectMapper.writeValueAsString(user);
final String jsonUser = OBJECT_MAPPER.writeValueAsString(user);
final String address = HttpHost.unsecure(container.httpMappedAddress()) + "/data/User";
final HttpPost post = new HttpPost(address);
final HttpEntity entity = new StringEntity(jsonUser, ContentType.APPLICATION_JSON);
Expand All @@ -50,7 +51,7 @@ public static List<User> sendUsers(List<User> users, TDGContainer<?> container)
+ ", "
+ response.getReasonPhrase());
}
return objectMapper.readValue(
return OBJECT_MAPPER.readValue(
EntityUtils.toString(response.getEntity()), User.class);
}));
}
Expand All @@ -59,7 +60,6 @@ public static List<User> sendUsers(List<User> users, TDGContainer<?> container)
}

public static List<User> getUsers(int count, TDGContainer<?> node) throws IOException {
final ObjectMapper objectMapper = new ObjectMapper();
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
final String address =
HttpHost.unsecure(node.httpMappedAddress()) + "/data/User?first=" + count;
Expand All @@ -73,7 +73,7 @@ public static List<User> getUsers(int count, TDGContainer<?> node) throws IOExce
+ ", "
+ response.getReasonPhrase());
}
return objectMapper.readValue(
return OBJECT_MAPPER.readValue(
EntityUtils.toString(response.getEntity()), new TypeReference<List<User>>() {});
});
}
Expand Down