Skip to content

Commit

Permalink
chore: Remove unused Clock reference (#2991)
Browse files Browse the repository at this point in the history
* Remove unused Clock reference

* Add missing brace to else
  • Loading branch information
jimmarino authored May 13, 2023
1 parent 38a158c commit a95be9b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private void registerServices(ServiceExtensionContext context) {
context.registerService(ContractOfferResolver.class, contractOfferResolver);

var policyEquality = new PolicyEquality(typeManager);
var validationService = new ContractValidationServiceImpl(participantId, agentService, definitionService, assetIndex, policyStore, policyEngine, policyEquality, clock);
var validationService = new ContractValidationServiceImpl(participantId, agentService, definitionService, assetIndex, policyStore, policyEngine, policyEquality);
context.registerService(ContractValidationService.class, validationService);

// bind/register rule to evaluate contract expiry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ private Duration asDuration(String rightValueStr) {
var number = Integer.parseInt(matcher.group(REGEX_GROUP_NUMERIC));
var unit = matcher.group(REGEX_GROUP_UNIT);
return Duration.of(number, asChrono(unit));
} else return null;
} else {
return null;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.eclipse.edc.spi.types.domain.asset.Asset;
import org.jetbrains.annotations.NotNull;

import java.time.Clock;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -59,24 +58,21 @@ public class ContractValidationServiceImpl implements ContractValidationService
private final PolicyDefinitionStore policyStore;
private final PolicyEngine policyEngine;
private final PolicyEquality policyEquality;
private final Clock clock;

public ContractValidationServiceImpl(String participantId,
ParticipantAgentService agentService,
ContractDefinitionResolver contractDefinitionResolver,
AssetIndex assetIndex,
PolicyDefinitionStore policyStore,
PolicyEngine policyEngine,
PolicyEquality policyEquality,
Clock clock) {
PolicyEquality policyEquality) {
this.participantId = participantId;
this.agentService = agentService;
this.contractDefinitionResolver = contractDefinitionResolver;
this.assetIndex = assetIndex;
this.policyStore = policyStore;
this.policyEngine = policyEngine;
this.policyEquality = policyEquality;
this.clock = clock;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,12 @@
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.ArgumentCaptor;

import java.time.Clock;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.Map;
import java.util.UUID;

import static java.lang.String.format;
import static java.time.Instant.MIN;
import static java.time.ZoneOffset.UTC;
import static java.util.Collections.emptyMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.connector.contract.spi.validation.ContractValidationService.NEGOTIATION_SCOPE;
Expand Down Expand Up @@ -81,7 +78,6 @@ class ContractValidationServiceImplTest {
private final ContractDefinitionResolver definitionResolver = mock(ContractDefinitionResolver.class);
private final AssetIndex assetIndex = mock(AssetIndex.class);
private final PolicyDefinitionStore policyStore = mock(PolicyDefinitionStore.class);
private final Clock clock = Clock.fixed(now, UTC);
private final PolicyEngine policyEngine = mock(PolicyEngine.class);
private final PolicyEquality policyEquality = mock(PolicyEquality.class);
private ContractValidationServiceImpl validationService;
Expand All @@ -96,7 +92,7 @@ private static ContractDefinition.Builder createContractDefinitionBuilder() {

@BeforeEach
void setUp() {
validationService = new ContractValidationServiceImpl(PROVIDER_ID, agentService, definitionResolver, assetIndex, policyStore, policyEngine, policyEquality, clock);
validationService = new ContractValidationServiceImpl(PROVIDER_ID, agentService, definitionResolver, assetIndex, policyStore, policyEngine, policyEquality);
when(assetIndex.countAssets(anyList())).thenReturn(1L);
}

Expand Down Expand Up @@ -140,7 +136,6 @@ void verifyContractOfferValidation_failedIfNoConsumerIdentity() {
var participantAgent = new ParticipantAgent(emptyMap(), emptyMap());
var originalPolicy = Policy.Builder.newInstance().target("a").build();
var asset = Asset.Builder.newInstance().id("1").build();
var contractDefinition = createContractDefinition();

when(agentService.createFor(isA(ClaimToken.class))).thenReturn(participantAgent);

Expand Down Expand Up @@ -478,7 +473,6 @@ private Result<ContractAgreement> validateAgreementDate(long signingDate) {
}

private ContractOffer createContractOffer(Asset asset, Policy policy) {
var now = ZonedDateTime.ofInstant(clock.instant(), clock.getZone());
return ContractOffer.Builder.newInstance()
.id(format("1:%s:3", asset.getId()))
.assetId(asset.getId())
Expand Down

0 comments on commit a95be9b

Please sign in to comment.