Skip to content

Commit

Permalink
fix spotbugs
Browse files Browse the repository at this point in the history
  • Loading branch information
m-nagarajan committed Sep 13, 2024
1 parent c266d99 commit f457fd5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum PushJobDetailsStatus {
private static final Set<Integer> TERMINAL_STATUSES =
new HashSet<>(Arrays.asList(COMPLETED.getValue(), ERROR.getValue(), KILLED.getValue()));

public static final Set<PushJobDetailsStatus> TERMINAL_FAILED_STATUSES = new HashSet<>(Arrays.asList(ERROR, KILLED));
private static final Set<PushJobDetailsStatus> TERMINAL_FAILED_STATUSES = new HashSet<>(Arrays.asList(ERROR, KILLED));
private final int value;

PushJobDetailsStatus(int value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.linkedin.venice.status;

import static com.linkedin.venice.status.PushJobDetailsStatus.COMPLETED;
import static com.linkedin.venice.status.PushJobDetailsStatus.ERROR;
import static com.linkedin.venice.status.PushJobDetailsStatus.KILLED;
import static com.linkedin.venice.status.PushJobDetailsStatus.isFailed;
import static com.linkedin.venice.status.PushJobDetailsStatus.isSucceeded;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

import org.testng.annotations.Test;


public class TestPushJobDetailsStatus {
@Test
public void testIsFailedOrIsSuccess() {
for (PushJobDetailsStatus status: PushJobDetailsStatus.values()) {
if (status == COMPLETED) {
assertTrue(isSucceeded(status));
assertFalse(isFailed(status));
} else if (status == ERROR || status == KILLED) {
assertTrue(isFailed(status));
assertFalse(isSucceeded(status));
} else {
assertFalse(isSucceeded(status));
assertFalse(isFailed(status));
}
}
}

@Test
public void testIsTerminal() {
for (PushJobDetailsStatus status: PushJobDetailsStatus.values()) {
if (status == COMPLETED || status == ERROR || status == KILLED) {
assertTrue(PushJobDetailsStatus.isTerminal(status.getValue()));
} else {
assertFalse(PushJobDetailsStatus.isTerminal(status.getValue()));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import static com.linkedin.venice.controller.VeniceHelixAdmin.emitPushJobDetailsMetrics;
import static com.linkedin.venice.controller.VeniceHelixAdmin.isPushJobFailedUserError;
import static com.linkedin.venice.status.PushJobDetailsStatus.COMPLETED;
import static com.linkedin.venice.status.PushJobDetailsStatus.ERROR;
import static com.linkedin.venice.status.PushJobDetailsStatus.KILLED;
import static com.linkedin.venice.status.PushJobDetailsStatus.isFailed;
import static com.linkedin.venice.status.PushJobDetailsStatus.isSucceeded;
import static org.mockito.Mockito.mock;
Expand All @@ -29,22 +26,6 @@


public class TestPushJobStatusStats {
@Test
public void testIsFailedOrIsSuccess() {
for (PushJobDetailsStatus status: PushJobDetailsStatus.values()) {
if (status == COMPLETED) {
assertTrue(isSucceeded(status));
assertFalse(isFailed(status));
} else if (status == ERROR || status == KILLED) {
assertTrue(isFailed(status));
assertFalse(isSucceeded(status));
} else {
assertFalse(isSucceeded(status));
assertFalse(isFailed(status));
}
}
}

@Test(dataProvider = "True-and-False", dataProviderClass = DataProviderUtils.class)
public void testEmitPushJobDetailsMetrics(boolean isIncrementalPush) {
PushJobDetails details = mock(PushJobDetails.class);
Expand Down

0 comments on commit f457fd5

Please sign in to comment.