Skip to content

Commit

Permalink
Simplify expected response data variable
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyeh committed Nov 21, 2023
1 parent 55934be commit c6671c6
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.api.migrated.StateValidatorBalanceData;
Expand Down Expand Up @@ -57,13 +56,13 @@ public void shouldGetSpecifiedValidatorBalancesFromState() throws Exception {
.build();
request.setRequestBody(List.of("1", "2"));

final Optional<ObjectAndMetaData<List<StateValidatorBalanceData>>> expectedData =
chainDataProvider.getStateValidatorBalances("head", List.of("1", "2")).get();
final ObjectAndMetaData<List<StateValidatorBalanceData>> expectedData =
chainDataProvider.getStateValidatorBalances("head", List.of("1", "2")).get().orElseThrow();

handler.handleRequest(request);

assertThat(request.getResponseCode()).isEqualTo(SC_OK);
assertThat(request.getResponseBody()).isEqualTo(expectedData.orElseThrow());
assertThat(request.getResponseBody()).isEqualTo(expectedData);
}

@Test
Expand All @@ -74,13 +73,13 @@ public void shouldGetAllValidatorBalancesFromState() throws Exception {
.pathParameter("state_id", "head")
.build();

final Optional<ObjectAndMetaData<List<StateValidatorBalanceData>>> expectedData =
chainDataProvider.getStateValidatorBalances("head", List.of()).get();
final ObjectAndMetaData<List<StateValidatorBalanceData>> expectedData =
chainDataProvider.getStateValidatorBalances("head", List.of()).get().orElseThrow();

handler.handleRequest(request);

assertThat(request.getResponseCode()).isEqualTo(SC_OK);
assertThat(request.getResponseBody()).isEqualTo(expectedData.orElseThrow());
assertThat(request.getResponseBody()).isEqualTo(expectedData);
}

@Test
Expand Down

0 comments on commit c6671c6

Please sign in to comment.