Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIRC-2117 Return empty result when search doesn't find anything #1485

Merged
merged 7 commits into from
Jul 19, 2024

Conversation

Maksat-Galymzhan
Copy link
Contributor

@Maksat-Galymzhan Maksat-Galymzhan commented Jul 10, 2024

Purpose

Return empty result when search doesn't find anything

Learning

CIRC-2117

@Maksat-Galymzhan Maksat-Galymzhan changed the base branch from master to ecs-tlr-feature July 10, 2024 10:48
@Maksat-Galymzhan Maksat-Galymzhan self-assigned this Jul 10, 2024
@Maksat-Galymzhan Maksat-Galymzhan marked this pull request as draft July 10, 2024 10:49
@Maksat-Galymzhan Maksat-Galymzhan marked this pull request as draft July 10, 2024 12:01
@Maksat-Galymzhan Maksat-Galymzhan marked this pull request as ready for review July 11, 2024 06:29
Comment on lines 83 to 84
IndividualResource instance = instancesFixture.basedUponDunkirk();
UUID instanceId = instance.getId();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we inline it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean like this?
UUID instanceId = instancesFixture.basedUponDunkirk().getId();
Since we do not call instance object, we could do like this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you use this variable only once

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, thanks!

Response response = get(String.format("query=(id==%s)", instanceId), 200);
JsonObject responseJson = response.getJson();

Assertions.assertTrue(responseJson.isEmpty());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest using the same import for assertions as seen throughout this test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing it, fix it

clearTempTenantId();

// make sure neither item exists in current tenant
assertThat(itemsFixture.getById(collegeItem.getId()).getResponse().getStatusCode(), is(404));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertThat(itemsFixture.getById(collegeItem.getId()).getResponse().getStatusCode(), is(404));
assertThat(itemsFixture.getById(collegeItem.getId()).getResponse().getStatusCode(), is(HttpStatus.NOT_FOUND));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

assertThat(itemsFixture.getById(universityItem.getId()).getResponse().getStatusCode(), is(404));

ResourceClient.forSearchClient().replace(instanceId, new JsonObject());
Response response = get(String.format("query=(id==%s)", instanceId), 200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Response response = get(String.format("query=(id==%s)", instanceId), 200);
Response response = get(String.format("query=(id==%s)", instanceId), HttpStatus.HTTP_OK);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 102 to 103
assertThat(itemsFixture.getById(collegeItem.getId()).getResponse().getStatusCode(), is(HttpStatus.HTTP_NOT_FOUND.toInt()));
assertThat(itemsFixture.getById(universityItem.getId()).getResponse().getStatusCode(), is(HttpStatus.HTTP_NOT_FOUND.toInt()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertThat(itemsFixture.getById(collegeItem.getId()).getResponse().getStatusCode(), is(HttpStatus.HTTP_NOT_FOUND.toInt()));
assertThat(itemsFixture.getById(universityItem.getId()).getResponse().getStatusCode(), is(HttpStatus.HTTP_NOT_FOUND.toInt()));
assertThat(itemsFixture.getById(collegeItem.getId()).getResponse().getStatusCode(),
is(HTTP_NOT_FOUND.toInt()));
assertThat(itemsFixture.getById(universityItem.getId()).getResponse().getStatusCode(),
is(HTTP_NOT_FOUND.toInt()));

assertThat(itemsFixture.getById(universityItem.getId()).getResponse().getStatusCode(), is(HttpStatus.HTTP_NOT_FOUND.toInt()));

ResourceClient.forSearchClient().replace(instanceId, new JsonObject());
Response response = get(String.format("query=(id==%s)", instanceId), HttpStatus.HTTP_OK.toInt());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Response response = get(String.format("query=(id==%s)", instanceId), HttpStatus.HTTP_OK.toInt());
Response response = get(String.format("query=(id==%s)", instanceId), HTTP_OK.toInt());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link

@Maksat-Galymzhan Maksat-Galymzhan merged commit 5bd43b6 into ecs-tlr-feature Jul 19, 2024
4 checks passed
@Maksat-Galymzhan Maksat-Galymzhan deleted the CIRC-2117 branch July 19, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants