Skip to content

Commit

Permalink
Refactoring tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza Jugon committed Nov 10, 2023
1 parent fd4d461 commit c067716
Showing 1 changed file with 17 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,8 @@ public final void afterEach() {
@Test
public void testGetMetadataWhenTableNotFoundReturnsEmptyList()
throws SQLException, InterruptedException, IOException {
HousekeepingMetadata testMetadata1 = testMetadataB;
HousekeepingMetadata testMetadata2 = testMetadataC;

for (HousekeepingMetadata testMetadata : Arrays.asList(testMetadata1, testMetadata2)) {
for (HousekeepingMetadata testMetadata : Arrays.asList(testMetadataB, testMetadataC)) {
insertExpiredMetadata(testMetadata);
}

Expand All @@ -129,15 +127,11 @@ public void testGetMetadataWhenTableNotFoundReturnsEmptyList()

@Test
public void testGetMetadataWhenThereIsFiltering() throws SQLException, InterruptedException, IOException {
HousekeepingMetadata testMetadata1 = testMetadataA;
HousekeepingMetadata testMetadata2 = testMetadataD;
HousekeepingMetadata testMetadata3 = testMetadataE;
testMetadataA.setHousekeepingStatus(HousekeepingStatus.FAILED);
testMetadataA.setCleanupTimestamp(LocalDateTime.parse("1999-05-05T10:41:20"));
testMetadataA.setCreationTimestamp(LocalDateTime.parse("1999-05-05T10:41:20"));

testMetadata1.setHousekeepingStatus(HousekeepingStatus.FAILED);
testMetadata1.setCleanupTimestamp(LocalDateTime.parse("1999-05-05T10:41:20"));
testMetadata1.setCreationTimestamp(LocalDateTime.parse("1999-05-05T10:41:20"));

for (HousekeepingMetadata testMetadata : Arrays.asList(testMetadata1, testMetadata2, testMetadata3)) {
for (HousekeepingMetadata testMetadata : Arrays.asList(testMetadataA, testMetadataD, testMetadataE)) {
insertExpiredMetadata(testMetadata);
}

Expand All @@ -155,21 +149,17 @@ public void testGetMetadataWhenThereIsFiltering() throws SQLException, Interrupt
.readValue(body, new TypeReference<RestResponsePage<HousekeepingMetadataResponse>>() {});
List<HousekeepingMetadataResponse> result = responsePage.getContent();

assertThatMetadataEqualsResponse(testMetadata1, result.get(0));
assertThatMetadataEqualsResponse(testMetadataA, result.get(0));
assertThat(result).hasSize(1);
}

@Test
public void testGetPathsWhenThereIsFiltering() throws SQLException, InterruptedException, IOException {
HousekeepingPath testPath1 = testPathA;
HousekeepingPath testPath2 = testPathB;
HousekeepingPath testPath3 = testPathC;

testPath1.setHousekeepingStatus(HousekeepingStatus.FAILED);
testPath1.setCleanupTimestamp(LocalDateTime.parse("1999-05-05T10:41:20"));
testPath1.setCreationTimestamp(LocalDateTime.parse("1999-05-05T10:41:20"));
testPathA.setHousekeepingStatus(HousekeepingStatus.FAILED);
testPathA.setCleanupTimestamp(LocalDateTime.parse("1999-05-05T10:41:20"));
testPathA.setCreationTimestamp(LocalDateTime.parse("1999-05-05T10:41:20"));

for (HousekeepingPath testPath : Arrays.asList(testPath1, testPath2, testPath3)) {
for (HousekeepingPath testPath : Arrays.asList(testPathA, testPathB, testPathC)) {
insertUnreferencedPath(testPath);
}
String filters = "?housekeeping_status=FAILED"
Expand All @@ -185,21 +175,18 @@ public void testGetPathsWhenThereIsFiltering() throws SQLException, InterruptedE
.readValue(body, new TypeReference<RestResponsePage<HousekeepingPathResponse>>() {});
List<HousekeepingPathResponse> result = responsePage.getContent();
assertThat(responsePage.getTotalElements()).isEqualTo(1L);
assertThatPathsEqualsResponse(testPath1, result.get(0));
assertThatPathsEqualsResponse(testPathA, result.get(0));
assertThat(result).hasSize(1);
}

@Test
public void testPathsPageable() throws SQLException, InterruptedException, IOException {
HousekeepingPath testPath1 = testPathA;
HousekeepingPath testPath2 = testPathB;
HousekeepingPath testPath3 = testPathC;

for (HousekeepingPath testPath : Arrays.asList(testPath1, testPath2, testPath3)) {
for (HousekeepingPath testPath : Arrays.asList(testPathA, testPathB, testPathC)) {
testPath.setHousekeepingStatus(HousekeepingStatus.FAILED);
}

for (HousekeepingPath testPath : Arrays.asList(testPath1, testPath2, testPath3)) {
for (HousekeepingPath testPath : Arrays.asList(testPathA, testPathB, testPathC)) {
insertUnreferencedPath(testPath);
}

Expand All @@ -218,15 +205,12 @@ public void testPathsPageable() throws SQLException, InterruptedException, IOExc

@Test
public void testMetadataPageable() throws SQLException, InterruptedException, IOException {
HousekeepingMetadata testMetadata1 = testMetadataA;
HousekeepingMetadata testMetadata2 = testMetadataB;
HousekeepingMetadata testMetadata3 = testMetadataC;

for (HousekeepingMetadata testPath : Arrays.asList(testMetadata1, testMetadata2, testMetadata3)) {
for (HousekeepingMetadata testPath : Arrays.asList(testMetadataA, testMetadataB, testMetadataC)) {
testPath.setHousekeepingStatus(HousekeepingStatus.FAILED);
}

for (HousekeepingMetadata testMetadata : Arrays.asList(testMetadata1, testMetadata2, testMetadata3)) {
for (HousekeepingMetadata testMetadata : Arrays.asList(testMetadataA, testMetadataB, testMetadataC)) {
insertExpiredMetadata(testMetadata);
}

Expand All @@ -247,17 +231,11 @@ public void testMetadataPageable() throws SQLException, InterruptedException, IO
@Disabled
@Test
public void manualTest() throws SQLException, InterruptedException {
HousekeepingMetadata testMetadata1 = testMetadataA;
HousekeepingMetadata testMetadata2 = testMetadataB;
HousekeepingMetadata testMetadata3 = testMetadataC;
for (HousekeepingMetadata testMetadata : Arrays.asList(testMetadata1, testMetadata2, testMetadata3)) {
for (HousekeepingMetadata testMetadata : Arrays.asList(testMetadataA, testMetadataB, testMetadataC)) {
insertExpiredMetadata(testMetadata);
}

HousekeepingPath testPath1 = testPathA;
HousekeepingPath testPath2 = testPathB;
HousekeepingPath testPath3 = testPathC;
for (HousekeepingPath testPath : Arrays.asList(testPath1, testPath2, testPath3)) {
for (HousekeepingPath testPath : Arrays.asList(testPathA, testPathB, testPathC)) {
insertUnreferencedPath(testPath);
}

Expand Down

0 comments on commit c067716

Please sign in to comment.