Skip to content

Commit

Permalink
[code style] Less error-prone HashMap in ConsoleOutputTest (#148)
Browse files Browse the repository at this point in the history
Signed-off-by: Sara Adams <[email protected]>
  • Loading branch information
saraadams authored Dec 4, 2023
1 parent 3657979 commit 1010a94
Showing 1 changed file with 22 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import com.engflow.bazel.invocation.analyzer.core.TestDatum.IntegerDatum;
import com.engflow.bazel.invocation.analyzer.core.TestDatum.StringDatum;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
Expand Down Expand Up @@ -211,27 +211,15 @@ public void formatAnalysisDataShouldIncludeData() {
var myChar = new CharDatum('L');
var myEmptyString = new StringDatum(null);

var data =
new HashMap<Class<? extends DataProvider>, Map<Class<? extends Datum>, Datum>>() {
{
put(
TestDataProvider.class,
new HashMap<>() {
{
put(IntegerDatum.class, myInt);
put(DoubleDatum.class, myDouble);
put(StringDatum.class, myEmptyString);
}
});
put(
TestDataProvider2.class,
new HashMap<>() {
{
put(CharDatum.class, myChar);
}
});
}
};
Map<Class<? extends DataProvider>, Map<Class<? extends Datum>, Datum>> data =
ImmutableMap.of(
TestDataProvider.class,
ImmutableMap.of(
IntegerDatum.class, myInt,
DoubleDatum.class, myDouble,
StringDatum.class, myEmptyString),
TestDataProvider2.class,
ImmutableMap.of(CharDatum.class, myChar));

ConsoleOutput consoleOutput = new ConsoleOutput(false, false);

Expand Down Expand Up @@ -259,27 +247,18 @@ public void formatAnalysisDataWithVerboseShouldIncludeVerboseData() {
var myChar = new CharDatum('L');
var myEmptyString = new StringDatum(null);

var data =
new HashMap<Class<? extends DataProvider>, Map<Class<? extends Datum>, Datum>>() {
{
put(
TestDataProvider.class,
new HashMap<>() {
{
put(IntegerDatum.class, myInt);
put(DoubleDatum.class, myDouble);
put(StringDatum.class, myEmptyString);
}
});
put(
TestDataProvider2.class,
new HashMap<>() {
{
put(CharDatum.class, myChar);
}
});
}
};
Map<Class<? extends DataProvider>, Map<Class<? extends Datum>, Datum>> data =
ImmutableMap.of(
TestDataProvider.class,
ImmutableMap.of(
IntegerDatum.class,
myInt,
DoubleDatum.class,
myDouble,
StringDatum.class,
myEmptyString),
TestDataProvider2.class,
ImmutableMap.of(CharDatum.class, myChar));

ConsoleOutput consoleOutput = new ConsoleOutput(false, true);

Expand Down

0 comments on commit 1010a94

Please sign in to comment.