Skip to content

Commit

Permalink
refactor: cleanup 0.6.x, 0.7.x and 0.8.x deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Jan 15, 2025
1 parent c547e75 commit 3841c64
Show file tree
Hide file tree
Showing 46 changed files with 113 additions and 686 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

package org.eclipse.edc.connector.core;

import org.eclipse.edc.junit.extensions.EdcExtension;
import org.eclipse.edc.junit.extensions.RuntimeExtension;
import org.eclipse.edc.junit.extensions.RuntimePerMethodExtension;
import org.eclipse.edc.spi.system.Hostname;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -25,11 +26,11 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.connector.core.CoreServicesExtension.EDC_HOSTNAME;

@ExtendWith(EdcExtension.class)
@ExtendWith(RuntimePerMethodExtension.class)
class CoreServicesExtensionIntegrationTest {

@BeforeEach
void setUp(EdcExtension extension) {
void setUp(RuntimeExtension extension) {
extension.setConfiguration(Map.of(EDC_HOSTNAME, "hostname"));
}

Expand All @@ -38,4 +39,4 @@ void shouldProvideHostnameExtension(Hostname hostname) {
assertThat(hostname.get()).isEqualTo("hostname");
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* extension attaches a dependency injection container to the test lifecycle. Parameter injection of runtime services is
* supported.
* <p>
* If additional lifecycle services are needed (detection, loading and booting of extensions), use {@link EdcExtension}
* If additional lifecycle services are needed (detection, loading and booting of extensions), use {@link RuntimeExtension}
* instead.
* The {@link ServiceExtensionContext} instance is wrapped by a Mockito Spy.
*/
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ public class ExpirationIssuedAtValidationRule implements TokenValidationRule {
private final int issuedAtLeeway;
private final boolean allowNull;

/**
* Instantiates the rule
*
* @deprecated Please use {@link ExpirationIssuedAtValidationRule#ExpirationIssuedAtValidationRule(Clock, int, boolean)} instead
*/
@Deprecated(since = "0.7.0")
public ExpirationIssuedAtValidationRule(Clock clock, int issuedAtLeeway) {
this(clock, issuedAtLeeway, false);
}

public ExpirationIssuedAtValidationRule(Clock clock, int issuedAtLeeway, boolean allowNull) {
this.clock = clock;
this.issuedAtLeeway = issuedAtLeeway;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ public class NotBeforeValidationRule implements TokenValidationRule {
private final int notBeforeLeeway;
private final boolean allowNull;

/**
* Instantiates the rule
*
* @deprecated Please use {@link NotBeforeValidationRule#NotBeforeValidationRule(Clock, int, boolean)} instead.
*/
@Deprecated(since = "0.7.0")
public NotBeforeValidationRule(Clock clock, int notBeforeLeeway) {
this(clock, notBeforeLeeway, false);
}

public NotBeforeValidationRule(Clock clock, int notBeforeLeeway, boolean allowNull) {
this.clock = clock;
this.notBeforeLeeway = notBeforeLeeway;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public JsonObjectFromDataPlaneInstanceV3Transformer(JsonBuilderFactory jsonFacto
.add(TYPE, DataPlaneInstance.DATAPLANE_INSTANCE_TYPE)
.add(URL, dataPlaneInstance.getUrl().toString())
.add(LAST_ACTIVE, dataPlaneInstance.getLastActive())
.add(TURN_COUNT, dataPlaneInstance.getTurnCount());
.add(TURN_COUNT, 0);

if (dataPlaneInstance.getProperties() != null && !dataPlaneInstance.getProperties().isEmpty()) {
var propBuilder = jsonFactory.createObjectBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ void transform() {
.allowedDestType("test-dest-type")
.allowedTransferType("test-transfer-type")
.lastActive(15)
.turnCount(42)
.property("foo", "bar")
.build();

Expand All @@ -67,10 +66,10 @@ void transform() {
assertThat(jsonObject.getString(ID)).isEqualTo("test-id");
assertThat(jsonObject.getString(URL)).isEqualTo("http://foo.bar");
assertThat(jsonObject.getJsonArray(ALLOWED_SOURCE_TYPES)).hasSize(1).allMatch(v -> ((JsonString) v).getString().equals("test-source-type"));
assertThat(jsonObject.getJsonArray(ALLOWED_DEST_TYPES)).hasSize(1).allMatch(v -> ((JsonString) v).getString().equals("test-dest-type"));
assertThat(jsonObject.getJsonArray(ALLOWED_DEST_TYPES)).hasSize(0);
assertThat(jsonObject.getJsonArray(ALLOWED_TRANSFER_TYPES)).hasSize(1).allMatch(v -> ((JsonString) v).getString().equals("test-transfer-type"));
assertThat(jsonObject.getJsonNumber(LAST_ACTIVE).intValue()).isEqualTo(15);
assertThat(jsonObject.getJsonNumber(TURN_COUNT).intValue()).isEqualTo(42);
assertThat(jsonObject.getJsonNumber(TURN_COUNT).intValue()).isEqualTo(0);
assertThat(jsonObject.getJsonObject(PROPERTIES).getJsonString("foo").getString()).isEqualTo("bar");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ExpirationIssuedAtValidationRuleTest {

private final Instant now = Instant.now().truncatedTo(ChronoUnit.SECONDS);
private final Clock clock = Clock.fixed(now, UTC);
private final TokenValidationRule rule = new ExpirationIssuedAtValidationRule(clock, 0);
private final TokenValidationRule rule = new ExpirationIssuedAtValidationRule(clock, 0, false);

@Test
void validationOk() {
Expand Down Expand Up @@ -110,7 +110,7 @@ void validationKoBecauseIssuedAtInFuture() {

@Test
void validationKoBecauseIssuedAtInFutureOutsideLeeway() {
var rule = new ExpirationIssuedAtValidationRule(clock, 5);
var rule = new ExpirationIssuedAtValidationRule(clock, 5, false);

var token = ClaimToken.Builder.newInstance()
.claim(EXPIRATION_TIME, Date.from(now.plusSeconds(60)))
Expand All @@ -125,7 +125,7 @@ void validationKoBecauseIssuedAtInFutureOutsideLeeway() {

@Test
void validationOkBecauseIssuedAtInFutureButWithinLeeway() {
var rule = new ExpirationIssuedAtValidationRule(clock, 20);
var rule = new ExpirationIssuedAtValidationRule(clock, 20, false);

var token = ClaimToken.Builder.newInstance()
.claim(EXPIRATION_TIME, Date.from(now.plusSeconds(60)))
Expand All @@ -152,7 +152,7 @@ void validationKoWithRoundedIssuedAtAndNoLeeway() {
var now = issuedAt.minus(250, ChronoUnit.MILLIS);

var clock = Clock.fixed(now, UTC);
var rule = new ExpirationIssuedAtValidationRule(clock, 0);
var rule = new ExpirationIssuedAtValidationRule(clock, 0, false);

var token = ClaimToken.Builder.newInstance()
.claim(EXPIRATION_TIME, Date.from(expiresAt))
Expand Down Expand Up @@ -180,7 +180,7 @@ void validationOkWithRoundedIssuedAtAndMinimalLeeway() {
var now = issuedAt.minus(250, ChronoUnit.MILLIS);

var clock = Clock.fixed(now, UTC);
var rule = new ExpirationIssuedAtValidationRule(clock, 2);
var rule = new ExpirationIssuedAtValidationRule(clock, 2, false);

var token = ClaimToken.Builder.newInstance()
.claim(EXPIRATION_TIME, Date.from(expiresAt))
Expand All @@ -191,4 +191,4 @@ void validationOkWithRoundedIssuedAtAndMinimalLeeway() {

assertThat(result.succeeded()).isTrue();
}
}
}
Loading

0 comments on commit 3841c64

Please sign in to comment.