Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/blue/language/processor/ContractLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ ContractBundle load(Node scopeNode, String scopePath) {
if (contract instanceof ChannelContract) {
ChannelContract channel = (ChannelContract) contract;
if (!ProcessorContractConstants.isProcessorManagedChannel(channel)
&& registry.lookupChannel(channel.getClass()).isEmpty()) {
&& !registry.lookupChannel(channel.getClass()).isPresent()) {
throw new MustUnderstandFailureException(
"Unsupported contract type: " + channel.getClass().getName());
}
builder.addChannel(key, channel);
} else if (contract instanceof HandlerContract) {
HandlerContract handler = (HandlerContract) contract;
if (registry.lookupHandler(handler.getClass()).isEmpty()) {
if (!registry.lookupHandler(handler.getClass()).isPresent()) {
throw new MustUnderstandFailureException(
"Unsupported contract type: " + handler.getClass().getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import blue.language.model.Node;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
Expand All @@ -18,12 +19,12 @@ public final class DocumentProcessingResult {
private final String failureReason;

private DocumentProcessingResult(Node document,
List<Node> triggeredEvents,
long totalGas,
boolean capabilityFailure,
String failureReason) {
List<Node> triggeredEvents,
long totalGas,
boolean capabilityFailure,
String failureReason) {
this.document = document;
this.triggeredEvents = Collections.unmodifiableList(triggeredEvents);
this.triggeredEvents = Collections.unmodifiableList(new ArrayList<>(triggeredEvents));
this.totalGas = totalGas;
this.capabilityFailure = capabilityFailure;
this.failureReason = failureReason;
Expand All @@ -32,12 +33,12 @@ private DocumentProcessingResult(Node document,
public static DocumentProcessingResult of(Node document, List<Node> triggeredEvents, long totalGas) {
Objects.requireNonNull(document, "document");
Objects.requireNonNull(triggeredEvents, "triggeredEvents");
return new DocumentProcessingResult(document, List.copyOf(triggeredEvents), totalGas, false, null);
return new DocumentProcessingResult(document, new ArrayList<>(triggeredEvents), totalGas, false, null);
}

public static DocumentProcessingResult capabilityFailure(Node document, String reason) {
Objects.requireNonNull(document, "document");
return new DocumentProcessingResult(document, List.of(), 0L, true, reason);
return new DocumentProcessingResult(document, Collections.emptyList(), 0L, true, reason);
}

public Node document() {
Expand All @@ -59,4 +60,4 @@ public boolean capabilityFailure() {
public String failureReason() {
return failureReason;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
import blue.language.utils.TypeClassResolver;
import org.junit.jupiter.api.Test;

import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.*;
Expand All @@ -26,7 +27,10 @@ class ContractMappingIntegrationTest {

@Test
void loadsAllContractsFromBlueYaml() throws Exception {
String yaml = Files.readString(Path.of("src/test/resources/processor/contracts/all-contracts.blue"));
String yaml = new String(
Files.readAllBytes(Paths.get("src/test/resources/processor/contracts/all-contracts.blue")),
StandardCharsets.UTF_8
);

Blue blue = new Blue();
Node document = blue.yamlToNode(yaml);
Expand Down
Loading