Skip to content

Commit

Permalink
Move the BackoffWrapper into api (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
kittylyst authored Jul 31, 2024
1 parent f1debd2 commit e5edc59
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (C) Red Hat 2023 */
package com.redhat.insights.core.httpclient;
/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.http;

import static com.redhat.insights.InsightsErrorCode.ERROR_CLIENT_BACKOFF_RETRIES_FAILED;
import static com.redhat.insights.InsightsErrorCode.ERROR_INTERRUPTED_THREAD;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (C) Red Hat 2023 */
package com.redhat.insights.core.httpclient;
/* Copyright (C) Red Hat 2023-2024 */
package com.redhat.insights.http;

import static org.junit.jupiter.api.Assertions.*;

Expand All @@ -13,16 +13,16 @@ class BackoffWrapperTest {

@Test
void notFailingAction() {
var logger = PrintLogger.STDOUT_LOGGER;
var backoff = new BackoffWrapper(logger, 100L, 2L, 3, () -> {});
PrintLogger logger = PrintLogger.STDOUT_LOGGER;
BackoffWrapper backoff = new BackoffWrapper(logger, 100L, 2L, 3, () -> {});
assertEquals(0, backoff.run());
}

@Test
void alwaysFailingAction() {
var start = System.currentTimeMillis();
var logger = PrintLogger.STDOUT_LOGGER;
var backoff =
long start = System.currentTimeMillis();
PrintLogger logger = PrintLogger.STDOUT_LOGGER;
BackoffWrapper backoff =
new BackoffWrapper(
logger,
10L,
Expand All @@ -45,10 +45,10 @@ void alwaysFailingAction() {

@Test
void eventuallySucceedingAction() {
var start = System.currentTimeMillis();
var count = new AtomicInteger(0);
var logger = PrintLogger.STDOUT_LOGGER;
var backoff =
long start = System.currentTimeMillis();
AtomicInteger count = new AtomicInteger(0);
PrintLogger logger = PrintLogger.STDOUT_LOGGER;
BackoffWrapper backoff =
new BackoffWrapper(
logger,
10L,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.redhat.insights.InsightsException;
import com.redhat.insights.config.InsightsConfiguration;
import com.redhat.insights.http.BackoffWrapper;
import com.redhat.insights.http.InsightsHttpClient;
import com.redhat.insights.logging.InsightsLogger;
import com.redhat.insights.reports.InsightsReport;
Expand Down

0 comments on commit e5edc59

Please sign in to comment.