Skip to content

Commit

Permalink
Remove unwanted assertions. Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
asloobq committed Oct 18, 2024
1 parent 78e61d0 commit 24ab08e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.uid2</groupId>
<artifactId>uid2-operator</artifactId>
<version>5.40.87-alpha-110-SNAPSHOT</version>
<version>5.40.86</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ public void handleMessage(Message message) {
return;
}

if (messageItem == null) {
throw new NullPointerException("Message could not be deserialized");
}

String path = messageItem.getPath();
String apiVersion = "v0";
String endpoint = path.substring(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,8 @@ private OptOutStoreSnapshot updateIndexInternal(IndexUpdateContext iuc) {
if (numPartitions == 0) {
// if update doesn't have a new partition, simply update heap with new log data
if (!iuc.getDeltasToRemove().isEmpty()) {
final String errorMsg = "Invalid number of Deltas to remove=" + iuc.getDeltasToRemove().size();
final String errorMsg = "Invalid number of Deltas to remove=" + iuc.getDeltasToRemove().size()
+ " when there are 0 new partitions to index";
LOGGER.error(errorMsg);
throw new IllegalStateException(errorMsg);
}
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/uid2/operator/util/Tuple.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.uid2.operator.util;

import java.util.Objects;

public class Tuple {
public static class Tuple2<T1, T2> {
private final T1 item1;
private final T2 item2;

public Tuple2(T1 item1, T2 item2) {
if (item1 == null || item2 == null) {
throw new NullPointerException();
}
Objects.requireNonNull(item1);
Objects.requireNonNull(item2);

this.item1 = item1;
this.item2 = item2;
Expand All @@ -35,9 +36,9 @@ public static class Tuple3<T1, T2, T3> {
private final T3 item3;

public Tuple3(T1 item1, T2 item2, T3 item3) {
if (item1 == null || item2 == null || item3 == null) {
throw new NullPointerException();
}
Objects.requireNonNull(item1);
Objects.requireNonNull(item2);
Objects.requireNonNull(item3);

this.item1 = item1;
this.item2 = item2;
Expand Down
12 changes: 5 additions & 7 deletions src/test/java/com/uid2/operator/V2RequestUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -153,11 +153,9 @@ public void testHandleRefreshTokenInResponseBody() {
when(keyManager.getRefreshKey()).thenReturn(refreshKey);
when(refreshKey.getId()).thenReturn(Integer.MAX_VALUE);
when(refreshKey.getKeyBytes()).thenReturn(Random.getRandomKeyBytes());
try {
V2RequestUtil.handleRefreshTokenInResponseBody(jsonBody, keyManager, IdentityScope.UID2);
fail("IllegalArgumentException not thrown");
} catch (IllegalArgumentException e) {
assertEquals("Generated refresh token's length=168 is not equal to=388", e.getMessage());
}
IllegalArgumentException e = assertThrowsExactly(
IllegalArgumentException.class,
() -> V2RequestUtil.handleRefreshTokenInResponseBody(jsonBody, keyManager, IdentityScope.UID2));
assertEquals("Generated refresh token's length=168 is not equal to=388", e.getMessage());
}
}

0 comments on commit 24ab08e

Please sign in to comment.