Skip to content

Commit

Permalink
feature: include connection status to query requests
Browse files Browse the repository at this point in the history
  • Loading branch information
EddeCCC committed Nov 6, 2024
1 parent 2cfa866 commit fe778be
Show file tree
Hide file tree
Showing 4 changed files with 399 additions and 362 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
public record QueryConnectionRequest(
@ValidRegexPattern(message = "Invalid registration time pattern") String registrationTime,
@ValidRegexPattern(message = "Invalid connection status pattern") String connectionStatus,
@Valid QueryAgentRequest agent) {

public record QueryAgentRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ private boolean matchesConnection(Connection connection, QueryConnectionRequest
regexQueryService.matches(
connection.getRegistrationTime().toString(), query.registrationTime());

matches &=
regexQueryService.matches(
connection.getConnectionStatus().toString(), query.connectionStatus());

if (query.agent() != null) {

QueryConnectionRequest.QueryAgentRequest queryAgent = query.agent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,14 @@ void get_connection_whenEverythingIsValid_shouldReturnOk() throws Exception {
.andExpect(content().json(objectMapper.writeValueAsString(connectionDto)));
}

// TODO updateConnection tests

@Test
void queryConnections_whenMultipleParametersAreDefined_shouldReturnOk() throws Exception {
QueryConnectionRequest queryRequest =
new QueryConnectionRequest(
LocalDateTime.now().toString(),
ConnectionStatus.CONNECTED.toString(),
new QueryConnectionRequest.QueryAgentRequest(
"service-name",
"12345",
Expand Down Expand Up @@ -179,6 +182,7 @@ void queryConnections_whenRegexInParameters_shouldReturnOk() throws Exception {
QueryConnectionRequest queryRequest =
new QueryConnectionRequest(
"^2023-04-[0-9]+T[0-9:]+Z$",
ConnectionStatus.CONNECTED.name(),
new QueryConnectionRequest.QueryAgentRequest(
"regex:^service-.*",
"12345L",
Expand Down Expand Up @@ -219,6 +223,7 @@ void queryConnections_whenRegexInParameters_shouldReturnOk() throws Exception {
void queryConnections_whenRegexInParametersIsInvalid_shouldReturnBadRequest() throws Exception {
QueryConnectionRequest queryRequest =
new QueryConnectionRequest(
null,
null,
new QueryConnectionRequest.QueryAgentRequest(
"regex:*service-.*", null, null, null, null, null, null, null));
Expand Down
Loading

0 comments on commit fe778be

Please sign in to comment.