Skip to content

Commit

Permalink
Restore API as deprecated
Browse files Browse the repository at this point in the history
Signed-off-by: Yannic Klem <Yannic.Klem@bosch.io>
  • Loading branch information
Yannic92 committed Mar 4, 2022
1 parent d81853e commit 4b30081
Show file tree
Hide file tree
Showing 48 changed files with 210 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public boolean supports(final String name) {
}

@Override
public List<String> resolve(final ConnectionId connectionId, final String placeholder) {
public List<String> resolveValues(final ConnectionId connectionId, final String placeholder) {
argumentNotEmpty(placeholder, "placeholder");
checkNotNull(connectionId, "Connection ID");
if (ID_PLACEHOLDER.equals(placeholder)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public String getPrefix() {
}

@Override
public List<String> resolve(final EntityId entityId, final String placeholder) {
public List<String> resolveValues(final EntityId entityId, final String placeholder) {
argumentNotEmpty(placeholder, "placeholder");
checkNotNull(entityId, "Entity ID");
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class ImmutableFeaturePlaceholder implements FeaturePlaceholder {
static final ImmutableFeaturePlaceholder INSTANCE = new ImmutableFeaturePlaceholder();

@Override
public List<String> resolve(final CharSequence featureId, final String placeholder) {
public List<String> resolveValues(final CharSequence featureId, final String placeholder) {
checkNotNull(featureId, "featureId");
argumentNotEmpty(placeholder, "placeholder");
if (ID_PLACEHOLDER.equals(placeholder)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public String getPrefix() {
}

@Override
public List<String> resolve(final EntityId policyId, final String placeholder) {
public List<String> resolveValues(final EntityId policyId, final String placeholder) {
argumentNotEmpty(placeholder, "placeholder");
checkNotNull(policyId, "Policy ID");
if (policyId instanceof PolicyId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public boolean supports(final String name) {
}

@Override
public List<String> resolve(@Nullable final AuthorizationContext authorizationContext, final String headerKey) {
public List<String> resolveValues(@Nullable final AuthorizationContext authorizationContext, final String headerKey) {
// precondition: supports(headerKey)
return Optional.ofNullable(authorizationContext)
.flatMap(context -> context.getAuthorizationSubjects()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public boolean supports(final String name) {
}

@Override
public List<String> resolve(final String input, final String name) {
public List<String> resolveValues(final String input, final String name) {
return supports(name) ? Collections.singletonList(input) : Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public String getPrefix() {
}

@Override
public List<String> resolve(final EntityId thingId, final String placeholder) {
public List<String> resolveValues(final EntityId thingId, final String placeholder) {
argumentNotEmpty(placeholder, "placeholder");
checkNotNull(thingId, "Thing ID");
if (thingId instanceof ThingId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public boolean supports(final String name) {
}

@Override
public List<String> resolve(final String placeholderSource, final String name) {
public List<String> resolveValues(final String placeholderSource, final String name) {
return supports(name) ? Collections.singletonList(placeholderSource) : Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void testPlaceholderResolver() {
final PlaceholderResolver<ConnectionId> underTest = PlaceholderFactory.newPlaceholderResolver(
ConnectivityPlaceholders.newConnectionIdPlaceholder(), connectionId);

assertThat(underTest.resolve("id"))
assertThat(underTest.resolveValues("id"))
.containsExactly(connectionId.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import java.util.Collections;
import java.util.List;
import java.util.Optional;

import org.eclipse.ditto.connectivity.model.ConnectionId;
import org.junit.Test;
Expand Down Expand Up @@ -46,13 +45,13 @@ public void supports() {
@Test
public void resolve() {
final String expectedResolvingResult = "myTestId";
final List<String> result = underTest.resolve(ConnectionId.of(expectedResolvingResult), "id");
final List<String> result = underTest.resolveValues(ConnectionId.of(expectedResolvingResult), "id");
assertThat(result).containsExactly(expectedResolvingResult);
}

@Test
public void resolveWithUnsupportedPlaceholder() {
final List<String> result = underTest.resolve(ConnectionId.of("myTestId"), "unsupported");
final List<String> result = underTest.resolveValues(ConnectionId.of("myTestId"), "unsupported");
assertThat(result).isEmpty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import org.eclipse.ditto.policies.model.PolicyId;
import org.eclipse.ditto.things.model.ThingId;
import org.junit.Ignore;
import org.junit.Test;
import org.mutabilitydetector.unittesting.MutabilityAssert;
import org.mutabilitydetector.unittesting.MutabilityMatchers;
Expand Down Expand Up @@ -56,37 +55,37 @@ public void testHashCodeAndEquals() {

@Test
public void testReplacePolicyId() {
assertThat(UNDER_TEST.resolve(POLICY_ID, "id")).contains(POLICY_ID.toString());
assertThat(UNDER_TEST.resolveValues(POLICY_ID, "id")).contains(POLICY_ID.toString());
}

@Test
public void testReplaceThingId() {
assertThat(UNDER_TEST.resolve(THING_ID, "id")).contains(THING_ID.toString());
assertThat(UNDER_TEST.resolveValues(THING_ID, "id")).contains(THING_ID.toString());
}

@Test
public void testReplacePolicyName() {
assertThat(UNDER_TEST.resolve(POLICY_ID, "name")).contains(NAME);
assertThat(UNDER_TEST.resolveValues(POLICY_ID, "name")).contains(NAME);
}

@Test
public void testReplaceThingName() {
assertThat(UNDER_TEST.resolve(THING_ID, "name")).contains(NAME);
assertThat(UNDER_TEST.resolveValues(THING_ID, "name")).contains(NAME);
}

@Test
public void testReplacePolicyNamespace() {
assertThat(UNDER_TEST.resolve(POLICY_ID, "namespace")).contains(NAMESPACE);
assertThat(UNDER_TEST.resolveValues(POLICY_ID, "namespace")).contains(NAMESPACE);
}

@Test
public void testReplaceThingNamespace() {
assertThat(UNDER_TEST.resolve(THING_ID, "namespace")).contains(NAMESPACE);
assertThat(UNDER_TEST.resolveValues(THING_ID, "namespace")).contains(NAMESPACE);
}

@Test
public void testUnknownPlaceholderReturnsEmpty() {
assertThat(UNDER_TEST.resolve(POLICY_ID, "policy_id")).isEmpty();
assertThat(UNDER_TEST.resolveValues(POLICY_ID, "policy_id")).isEmpty();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Ignore;
import org.junit.Test;
import org.mutabilitydetector.unittesting.MutabilityAssert;
import org.mutabilitydetector.unittesting.MutabilityMatchers;
Expand Down Expand Up @@ -45,12 +44,12 @@ public void testHashCodeAndEquals() {

@Test
public void testReplaceFeatureId() {
assertThat(UNDER_TEST.resolve(FEATURE_ID, "id")).contains(FEATURE_ID);
assertThat(UNDER_TEST.resolveValues(FEATURE_ID, "id")).contains(FEATURE_ID);
}

@Test
public void testUnknownPlaceholderReturnsEmpty() {
assertThat(UNDER_TEST.resolve(FEATURE_ID, "feature_id")).isEmpty();
assertThat(UNDER_TEST.resolveValues(FEATURE_ID, "feature_id")).isEmpty();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import static org.assertj.core.api.Assertions.assertThat;

import org.eclipse.ditto.policies.model.PolicyId;
import org.junit.Ignore;
import org.junit.Test;
import org.mutabilitydetector.unittesting.MutabilityAssert;
import org.mutabilitydetector.unittesting.MutabilityMatchers;
Expand Down Expand Up @@ -54,22 +53,22 @@ public void testHashCodeAndEquals() {

@Test
public void testReplacePolicyId() {
assertThat(UNDER_TEST.resolve(POLICY_ID, "id")).contains(POLICY_ID.toString());
assertThat(UNDER_TEST.resolveValues(POLICY_ID, "id")).contains(POLICY_ID.toString());
}

@Test
public void testReplacePolicyName() {
assertThat(UNDER_TEST.resolve(POLICY_ID, "name")).contains(NAME);
assertThat(UNDER_TEST.resolveValues(POLICY_ID, "name")).contains(NAME);
}

@Test
public void testReplacePolicyNamespace() {
assertThat(UNDER_TEST.resolve(POLICY_ID, "namespace")).contains(NAMESPACE);
assertThat(UNDER_TEST.resolveValues(POLICY_ID, "namespace")).contains(NAMESPACE);
}

@Test
public void testUnknownPlaceholderReturnsEmpty() {
assertThat(UNDER_TEST.resolve(POLICY_ID, "policy_id")).isEmpty();
assertThat(UNDER_TEST.resolveValues(POLICY_ID, "policy_id")).isEmpty();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import static org.mutabilitydetector.unittesting.MutabilityAssert.assertInstancesOf;
import static org.mutabilitydetector.unittesting.MutabilityMatchers.areImmutable;

import org.junit.Ignore;
import org.junit.Test;

/**
Expand All @@ -33,11 +32,11 @@ public void testImmutability() {

@Test
public void testReplaceTopic() {
assertThat(ImmutableSourceAddressPlaceholder.INSTANCE.resolve(SOME_MQTT_TOPIC, "address")).contains(SOME_MQTT_TOPIC);
assertThat(ImmutableSourceAddressPlaceholder.INSTANCE.resolveValues(SOME_MQTT_TOPIC, "address")).contains(SOME_MQTT_TOPIC);
}

@Test
public void testResultIsEmptyForUnknownPlaceholder() {
assertThat(ImmutableSourceAddressPlaceholder.INSTANCE.resolve(SOME_MQTT_TOPIC, "invalid")).isEmpty();
assertThat(ImmutableSourceAddressPlaceholder.INSTANCE.resolveValues(SOME_MQTT_TOPIC, "invalid")).isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import org.eclipse.ditto.things.model.ThingId;
import org.junit.Ignore;
import org.junit.Test;
import org.mutabilitydetector.unittesting.MutabilityAssert;
import org.mutabilitydetector.unittesting.MutabilityMatchers;
Expand Down Expand Up @@ -55,34 +54,34 @@ public void testHashCodeAndEquals() {

@Test
public void testReplaceThingId() {
assertThat(UNDER_TEST.resolve(THING_ID, "id")).contains(THING_ID.toString());
assertThat(UNDER_TEST.resolveValues(THING_ID, "id")).contains(THING_ID.toString());
}

@Test
public void testReplaceThingName() {
assertThat(UNDER_TEST.resolve(THING_ID, "name")).contains(NAME);
assertThat(UNDER_TEST.resolveValues(THING_ID, "name")).contains(NAME);
}

@Test
public void testReplaceThingNamespace() {
assertThat(UNDER_TEST.resolve(THING_ID, "namespace")).contains(NAMESPACE);
assertThat(UNDER_TEST.resolveValues(THING_ID, "namespace")).contains(NAMESPACE);
}

@Test
public void testUnknownPlaceholderReturnsEmpty() {
assertThat(UNDER_TEST.resolve(THING_ID, "thing_id")).isEmpty();
assertThat(UNDER_TEST.resolveValues(THING_ID, "thing_id")).isEmpty();
}

@Test
public void testResolvingWithNull() {
assertThatExceptionOfType(NullPointerException.class)
.isThrownBy(() -> UNDER_TEST.resolve(THING_ID, null));
.isThrownBy(() -> UNDER_TEST.resolveValues(THING_ID, null));
}

@Test
public void testResolvingWithEmptyString() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> UNDER_TEST.resolve(THING_ID, ""));
.isThrownBy(() -> UNDER_TEST.resolveValues(THING_ID, ""));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ public void testPlaceholderResolver() {
final PlaceholderResolver<TopicPath> underTest = PlaceholderFactory.newPlaceholderResolver(
ConnectivityPlaceholders.newTopicPathPlaceholder(), topic);

assertThat(underTest.resolve("full"))
assertThat(underTest.resolveValues("full"))
.containsExactly(fullPath);
assertThat(underTest.resolve("namespace"))
assertThat(underTest.resolveValues("namespace"))
.containsExactly("org.eclipse.ditto");
assertThat(underTest.resolve("entityName"))
assertThat(underTest.resolveValues("entityName"))
.containsExactly("foo23");
assertThat(underTest.resolve("group"))
assertThat(underTest.resolveValues("group"))
.containsExactly("things");
assertThat(underTest.resolve("channel"))
assertThat(underTest.resolveValues("channel"))
.containsExactly("twin");
assertThat(underTest.resolve("criterion"))
assertThat(underTest.resolveValues("criterion"))
.containsExactly("commands");
assertThat(underTest.resolve("action"))
assertThat(underTest.resolveValues("action"))
.containsExactly("modify");
}

Expand All @@ -99,9 +99,9 @@ public void testPlaceholderFilter() {


assertThatExceptionOfType(NullPointerException.class).isThrownBy(
() -> topicPlaceholder.resolve(knownTopicPath, null));
() -> topicPlaceholder.resolveValues(knownTopicPath, null));
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(
() -> topicPlaceholder.resolve(knownTopicPath, ""));
() -> topicPlaceholder.resolveValues(knownTopicPath, ""));
assertThatExceptionOfType(UnresolvedPlaceholderException.class).isThrownBy(
() -> PlaceholderFilter.apply("{{ topic:unknown }}", knownTopicPath, topicPlaceholder));
assertThatExceptionOfType(UnresolvedPlaceholderException.class).isThrownBy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private static ExpressionResolver getExpressionResolver(final Map<String, String

private static String potentiallySubstitutePlaceholders(final String stringValue,
final ExpressionResolver expressionResolver) {
return expressionResolver.resolvePartially(stringValue, Set.of()).findFirst().orElse(stringValue);
return expressionResolver.resolvePartiallyAsPipelineElement(stringValue, Set.of()).findFirst().orElse(stringValue);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private Mqtt3HeaderPlaceholder() {
}

@Override
public List<String> resolve(final String placeholderSource, final String name) {
public List<String> resolveValues(final String placeholderSource, final String name) {
throw new UnsupportedOperationException("This placeholder is only used for validation and does not " +
"resolve the placeholder.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ public boolean supports(final String name) {
}

@Override
public List<String> resolve(final String placeholderSource, final String name) {
public List<String> resolveValues(final String placeholderSource, final String name) {
return Collections.singletonList(placeholderSource);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Set<SubjectId> getSubjectIds(final DittoHeaders dittoHeaders, final JsonW
PlaceholderFactory.newPlaceholderResolver(PlaceholderFactory.newHeadersPlaceholder(), dittoHeaders),
PlaceholderFactory.newPlaceholderResolver(JwtPlaceholder.getInstance(), jwt)
);
return expressionResolver.resolvePartially(subjectTemplate, Set.of(JwtPlaceholder.PREFIX))
return expressionResolver.resolvePartiallyAsPipelineElement(subjectTemplate, Set.of(JwtPlaceholder.PREFIX))
.toStream()
.map(SubjectId::newInstance)
.collect(Collectors.toCollection(LinkedHashSet::new));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public boolean supports(final String name) {
}

@Override
public List<String> resolve(final JsonWebToken jwt, final String placeholder) {
public List<String> resolveValues(final JsonWebToken jwt, final String placeholder) {
argumentNotEmpty(placeholder, "placeholder");
checkNotNull(jwt, "jwt");
final Optional<JsonValue> value = jwt.getBody().getValue(placeholder);
Expand Down
Loading

0 comments on commit 4b30081

Please sign in to comment.