From d853eb73f6085006e7f94ab0f9b3218e6fc47be9 Mon Sep 17 00:00:00 2001 From: Hamza Jugon Date: Fri, 10 Nov 2023 15:09:39 +0000 Subject: [PATCH] Refactoring tests --- .../api/BeekeeperApiIntegrationTest.java | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/beekeeper-integration-tests/src/test/java/com/expediagroup/beekeeper/integration/api/BeekeeperApiIntegrationTest.java b/beekeeper-integration-tests/src/test/java/com/expediagroup/beekeeper/integration/api/BeekeeperApiIntegrationTest.java index f2d73e67..c311dde0 100644 --- a/beekeeper-integration-tests/src/test/java/com/expediagroup/beekeeper/integration/api/BeekeeperApiIntegrationTest.java +++ b/beekeeper-integration-tests/src/test/java/com/expediagroup/beekeeper/integration/api/BeekeeperApiIntegrationTest.java @@ -85,11 +85,11 @@ public ObjectMapper geObjectMapper() { protected final HousekeepingPath testPathA = createHousekeepingPath(someTable, pathA, LifecycleEventType.EXPIRED, duration.toString(), HousekeepingStatus.FAILED); protected final HousekeepingPath testPathB = createHousekeepingPath(someTable, pathB, LifecycleEventType.UNREFERENCED, duration.toString(), HousekeepingStatus.FAILED); protected final HousekeepingPath testPathC = createHousekeepingPath(someTable, pathC, LifecycleEventType.UNREFERENCED, duration.toString(), HousekeepingStatus.FAILED); - protected final HousekeepingMetadata testMetadataA = createHousekeepingMetadata(someTable, pathA, partitionA, LifecycleEventType.EXPIRED, duration.toString()); - protected final HousekeepingMetadata testMetadataB = createHousekeepingMetadata(someTable, pathB, partitionB, LifecycleEventType.EXPIRED, duration.toString()); - protected final HousekeepingMetadata testMetadataC = createHousekeepingMetadata(someTable, pathC, partitionC, LifecycleEventType.EXPIRED, duration.toString()); - protected final HousekeepingMetadata testMetadataD = createHousekeepingMetadata(someTable, pathC, partitionB, LifecycleEventType.UNREFERENCED, duration.toString()); - protected final HousekeepingMetadata testMetadataE = createHousekeepingMetadata(someTable, pathC, partitionC, LifecycleEventType.UNREFERENCED, duration.toString()); + protected final HousekeepingMetadata testMetadataA = createHousekeepingMetadata(someTable, pathA, partitionA, LifecycleEventType.EXPIRED, duration.toString(),HousekeepingStatus.FAILED); + protected final HousekeepingMetadata testMetadataB = createHousekeepingMetadata(someTable, pathB, partitionB, LifecycleEventType.EXPIRED, duration.toString(),HousekeepingStatus.FAILED); + protected final HousekeepingMetadata testMetadataC = createHousekeepingMetadata(someTable, pathC, partitionC, LifecycleEventType.EXPIRED, duration.toString(),HousekeepingStatus.FAILED); + protected final HousekeepingMetadata testMetadataD = createHousekeepingMetadata(someTable, pathC, partitionB, LifecycleEventType.UNREFERENCED, duration.toString(), HousekeepingStatus.SCHEDULED); + protected final HousekeepingMetadata testMetadataE = createHousekeepingMetadata(someTable, pathC, partitionC, LifecycleEventType.UNREFERENCED, duration.toString(),HousekeepingStatus.SCHEDULED); @BeforeEach public void beforeEach() { int port = SocketUtils.findAvailableTcpPort(); @@ -127,7 +127,6 @@ public void testGetMetadataWhenTableNotFoundReturnsEmptyList() @Test public void testGetMetadataWhenThereIsFiltering() throws SQLException, InterruptedException, IOException { - testMetadataA.setHousekeepingStatus(HousekeepingStatus.FAILED); testMetadataA.setCleanupTimestamp(LocalDateTime.parse("1999-05-05T10:41:20")); testMetadataA.setCreationTimestamp(LocalDateTime.parse("1999-05-05T10:41:20")); @@ -155,7 +154,6 @@ public void testGetMetadataWhenThereIsFiltering() throws SQLException, Interrupt @Test public void testGetPathsWhenThereIsFiltering() throws SQLException, InterruptedException, IOException { - testPathA.setHousekeepingStatus(HousekeepingStatus.FAILED); testPathA.setCleanupTimestamp(LocalDateTime.parse("1999-05-05T10:41:20")); testPathA.setCreationTimestamp(LocalDateTime.parse("1999-05-05T10:41:20")); @@ -181,11 +179,6 @@ public void testGetPathsWhenThereIsFiltering() throws SQLException, InterruptedE @Test public void testPathsPageable() throws SQLException, InterruptedException, IOException { - - for (HousekeepingPath testPath : Arrays.asList(testPathA, testPathB, testPathC)) { - testPath.setHousekeepingStatus(HousekeepingStatus.FAILED); - } - for (HousekeepingPath testPath : Arrays.asList(testPathA, testPathB, testPathC)) { insertUnreferencedPath(testPath); } @@ -205,11 +198,6 @@ public void testPathsPageable() throws SQLException, InterruptedException, IOExc @Test public void testMetadataPageable() throws SQLException, InterruptedException, IOException { - - for (HousekeepingMetadata testPath : Arrays.asList(testMetadataA, testMetadataB, testMetadataC)) { - testPath.setHousekeepingStatus(HousekeepingStatus.FAILED); - } - for (HousekeepingMetadata testMetadata : Arrays.asList(testMetadataA, testMetadataB, testMetadataC)) { insertExpiredMetadata(testMetadata); } @@ -273,7 +261,8 @@ private HousekeepingMetadata createHousekeepingMetadata( String path, String partitionName, LifecycleEventType lifecycleEventType, - String cleanupDelay) { + String cleanupDelay, + HousekeepingStatus housekeepingStatus) { return HousekeepingMetadata .builder() .id(id++) @@ -281,7 +270,7 @@ private HousekeepingMetadata createHousekeepingMetadata( .databaseName(DATABASE_NAME_VALUE) .tableName(tableName) .partitionName(partitionName) - .housekeepingStatus(SCHEDULED) + .housekeepingStatus(housekeepingStatus) .creationTimestamp(CREATION_TIMESTAMP_VALUE) .modifiedTimestamp(CREATION_TIMESTAMP_VALUE) .cleanupDelay(PeriodDuration.parse(cleanupDelay)) @@ -303,7 +292,7 @@ private HousekeepingPath createHousekeepingPath( .path(path) .databaseName(DATABASE_NAME_VALUE) .tableName(tableName) - .housekeepingStatus(SCHEDULED) + .housekeepingStatus(housekeepingStatus) .creationTimestamp(CREATION_TIMESTAMP_VALUE) .modifiedTimestamp(CREATION_TIMESTAMP_VALUE) .cleanupDelay(PeriodDuration.parse(cleanupDelay))