SpringBoot: rename VirtualNodes to VirtualNodeList

This commit is contained in:
djmil 2023-08-31 16:02:05 +02:00
parent 806c619588
commit 07970f31b2
3 changed files with 12 additions and 11 deletions

View File

@ -11,7 +11,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import djmil.cordacheckers.cordaclient.dao.VirtualNode; import djmil.cordacheckers.cordaclient.dao.VirtualNode;
import djmil.cordacheckers.cordaclient.dao.VirtualNodes; import djmil.cordacheckers.cordaclient.dao.VirtualNodeList;
@Service @Service
public class CordaClient { public class CordaClient {
@ -33,11 +33,11 @@ public class CordaClient {
// Request // Request
final HttpEntity<String> request = new HttpEntity<>(headers); final HttpEntity<String> request = new HttpEntity<>(headers);
ResponseEntity<VirtualNodes> resp = this.restTemplate.exchange( ResponseEntity<VirtualNodeList> resp = this.restTemplate.exchange(
"https://localhost:8888/api/v1/virtualnode", "https://localhost:8888/api/v1/virtualnode",
HttpMethod.GET, HttpMethod.GET,
request, request,
VirtualNodes.class ); VirtualNodeList.class );
// TODO: throw exeption instead // TODO: throw exeption instead
if (resp.getStatusCode() != HttpStatus.OK || !resp.hasBody()) { if (resp.getStatusCode() != HttpStatus.OK || !resp.hasBody()) {

View File

@ -5,4 +5,4 @@ import java.util.List;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public record VirtualNodes(List<VirtualNode> virtualNodes) { } public record VirtualNodeList(List<VirtualNode> virtualNodes) { }

View File

@ -28,6 +28,7 @@ import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import djmil.cordacheckers.cordaclient.dao.HoldingIdentity; import djmil.cordacheckers.cordaclient.dao.HoldingIdentity;
import djmil.cordacheckers.cordaclient.dao.VirtualNodeList;
import djmil.cordacheckers.cordaclient.dao.VirtualNodes; import djmil.cordacheckers.cordaclient.dao.VirtualNodes;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -80,19 +81,19 @@ class CordacheckersApplicationTests {
// Request // Request
final HttpEntity<String> request = new HttpEntity<>(headers); final HttpEntity<String> request = new HttpEntity<>(headers);
final ResponseEntity<VirtualNodes> response = new RestTemplate(requestFactory) final ResponseEntity<VirtualNodeList> response = new RestTemplate(requestFactory)
.exchange("https://localhost:8888/api/v1/virtualnode", HttpMethod.GET, request, VirtualNodes.class); .exchange("https://localhost:8888/api/v1/virtualnode", HttpMethod.GET, request, VirtualNodeList.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.hasBody()); assertThat(response.hasBody());
VirtualNodes vNode = response.getBody(); VirtualNodeList vNodeList = response.getBody();
assertThat(vNode).isNotNull(); assertThat(vNodeList).isNotNull();
if (vNode != null) { if (vNodeList != null) {
assertThat(vNode.virtualNodes().size() == 5); assertThat(vNodeList.virtualNodes().size() == 5);
} }
HoldingIdentity identity = vNode.virtualNodes().get(0).holdingIdentity(); HoldingIdentity identity = vNodeList.virtualNodes().get(0).holdingIdentity();
assertThat(identity.x500Name().contains("NotaryRep1")); assertThat(identity.x500Name().contains("NotaryRep1"));
} }
} }