Skip to content

Commit

Permalink
Unnecessary boxing was removed from tests (#30250)
Browse files Browse the repository at this point in the history
  • Loading branch information
Captain1653 committed May 31, 2021
1 parent 622d8af commit 206dafa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 26 deletions.
9 changes: 1 addition & 8 deletions akka-actor-tests/src/test/java/akka/actor/JavaAPI.java
Expand Up @@ -194,14 +194,7 @@ public ActorWithConstructorParams(int d) {
}

public void onReceive(Object msg) {
String reply =
String.valueOf(a)
+ "-"
+ String.valueOf(b)
+ "-"
+ String.valueOf(c)
+ "-"
+ String.valueOf(d);
String reply = a + "-" + b + "-" + c + "-" + d;
getSender().tell(reply, getSelf());
}
}
Expand Down
Expand Up @@ -16,7 +16,7 @@ private static int testReceive(
Object msg, int count, ActorRef sender, ActorRef self, UnrestrictedStash stash) {
if (msg instanceof String) {
if (count < 0) {
sender.tell(Integer.valueOf(((String) msg).length()), self);
sender.tell(((String) msg).length(), self);
} else if (count == 2) {
stash.unstashAll();
return -1;
Expand Down
22 changes: 5 additions & 17 deletions akka-actor-tests/src/test/java/akka/japi/MatchBuilderTest.java
Expand Up @@ -6,10 +6,7 @@

import akka.japi.pf.FI;
import akka.japi.pf.Match;
import org.junit.Rule;
import org.junit.Assert;
import org.junit.function.ThrowingRunnable;
import org.junit.rules.ExpectedException;
import org.junit.Test;
import org.scalatestplus.junit.JUnitSuite;
import scala.MatchError;
Expand Down Expand Up @@ -47,13 +44,7 @@ public Double apply(Number number) {
Double.valueOf(-47110).equals(pf.match(Double.valueOf(4711))));

Assert.assertThrows(
"A string should throw a MatchError",
MatchError.class,
new ThrowingRunnable() {
public void run() {
pf.match("4711");
}
});
"A string should throw a MatchError", MatchError.class, () -> pf.match("4711"));
}

static class GenericClass<T> {
Expand All @@ -77,9 +68,10 @@ public String apply(GenericClass<String> stringGenericClass) {
}
}));

assertTrue(
assertEquals(
"String value should be extract from GenericMessage",
"A".equals(pf.match(new GenericClass<String>("A"))));
"A",
pf.match(new GenericClass<>("A")));
}

@Test
Expand All @@ -104,10 +96,6 @@ public String apply(GenericClass<String> stringGenericClass) {
Assert.assertThrows(
"empty GenericMessage should throw match error",
MatchError.class,
new ThrowingRunnable() {
public void run() {
pf.match(new GenericClass<String>(""));
}
});
() -> pf.match(new GenericClass<>("")));
}
}

0 comments on commit 206dafa

Please sign in to comment.