Skip to content

refactor: attribute association expression rename #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 9, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import org.hypertrace.core.graphql.common.schema.attributes.arguments.AttributeExpression;

public interface AttributeRequest {
AttributeAssociation<AttributeExpression> attributeExpression();
AttributeAssociation<AttributeExpression> attributeExpressionAssociation();

default String asMapKey() {
return attributeExpression().value().asAlias();
return attributeExpressionAssociation().value().asAlias();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ private Stream<AttributeExpression> resolveAttributeExpression(SelectedField att
@Value
@Accessors(fluent = true)
static class DefaultAttributeRequest implements AttributeRequest {
AttributeAssociation<AttributeExpression> attributeExpression;
AttributeAssociation<AttributeExpression> attributeExpressionAssociation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ void canBuildRequestForSelectionSet() {
.blockingGet();

assertEquals(1, returned.size());
assertEquals(expectedResultExpression, returned.get(0).attributeExpression());
assertEquals(expectedResultExpression, returned.get(0).attributeExpressionAssociation());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ class AttributeExpressionConverter
implements Converter<AttributeAssociation<AttributeExpression>, Expression> {

@Override
public Single<Expression> convert(AttributeAssociation<AttributeExpression> attributeExpression) {
public Single<Expression> convert(
AttributeAssociation<AttributeExpression> attributeExpressionAssociation) {
Builder builder = org.hypertrace.gateway.service.v1.common.AttributeExpression.newBuilder();
builder.setAttributeId(attributeExpression.attribute().id());
attributeExpression.value().subpath().ifPresent(builder::setSubpath);
builder.setAlias(attributeExpression.value().asAlias());
builder.setAttributeId(attributeExpressionAssociation.attribute().id());
attributeExpressionAssociation.value().subpath().ifPresent(builder::setSubpath);
builder.setAlias(attributeExpressionAssociation.value().asAlias());
return Single.just(Expression.newBuilder().setAttributeExpression(builder).build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ private Single<Entry<AttributeExpression, Object>> buildAttributeMapEntry(
return this.valueConverter
.convert(
response.get(attributeRequest.asMapKey()),
attributeRequest.attributeExpression().attribute())
attributeRequest.attributeExpressionAssociation().attribute())
.map(
value ->
new SimpleImmutableEntry<>(attributeRequest.attributeExpression().value(), value));
new SimpleImmutableEntry<>(
attributeRequest.attributeExpressionAssociation().value(), value));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public Single<Set<Expression>> convert(Collection<AttributeRequest> attributeReq

private Single<Expression> buildAliasedSelectionExpression(AttributeRequest attributeRequest) {
return this.attributeExpressionConverter
.convert(attributeRequest.attributeExpression())
.convert(attributeRequest.attributeExpressionAssociation())
.map(Expression::toBuilder)
.map(Builder::build);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static class DefaultLogEventRequest implements LogEventRequest {
@Value
@Accessors(fluent = true)
static class DefaultAttributeRequest implements AttributeRequest {
AttributeAssociation<AttributeExpression> attributeExpression;
AttributeAssociation<AttributeExpression> attributeExpressionAssociation;
}

@Value
Expand Down
5 changes: 4 additions & 1 deletion hypertrace-core-graphql-platform/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ dependencies {
api("io.github.graphql-java:graphql-java-annotations:8.3")
api("org.slf4j:slf4j-api:1.7.30")
api("io.reactivex.rxjava3:rxjava:3.0.9")
api("com.google.protobuf:protobuf-java-util:3.14.0")
api("com.google.protobuf:protobuf-java-util:3.19.2")
api("com.google.protobuf:protobuf-java:3.19.2") {
because("https://snyk.io/vuln/SNYK-JAVA-COMGOOGLEPROTOBUF-2331703")
}

api("org.projectlombok:lombok:1.18.18")
api("com.google.code.findbugs:jsr305:3.0.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ private Single<Span> convert(
new ConvertedSpan(
attrMap
.get(
request.spanEventsRequest().idAttribute().attributeExpression().value())
request
.spanEventsRequest()
.idAttribute()
.attributeExpressionAssociation()
.value())
.toString(),
attrMap,
spanIdToLogEvents));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DaoTestUtil {
@Value
@Accessors(fluent = true)
static class DefaultAttributeRequest implements AttributeRequest {
AttributeAssociation<AttributeExpression> attributeExpression;
AttributeAssociation<AttributeExpression> attributeExpressionAssociation;
}

@Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,18 @@ protected void configure() {
return Single.just(
List.of(
AttributeAssociation.of(
spanIdAttribute.attributeExpression().attribute(),
spanIdAttribute.attributeExpressionAssociation().attribute(),
new NormalizedFilter(
AttributeExpression.forAttributeKey(
spanIdAttribute.attributeExpression().value().key()),
spanIdAttribute.attributeExpressionAssociation().value().key()),
filterArgument.operator(),
filterArgument.value()))));
})
.when(filterRequestBuilder)
.build(any(), any(), anyCollection());

when(attributeStore.getForeignIdAttribute(any(), anyString(), anyString()))
.thenReturn(Single.just(spanIdAttribute.attributeExpression().attribute()));
.thenReturn(Single.just(spanIdAttribute.attributeExpressionAssociation().attribute()));

doAnswer(
invocation -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ void testBuildResponse() {
List.of(spanIdAttribute, traceIdAttribute, attributesAttribute);

when(attributeStore.getForeignIdAttribute(any(), anyString(), anyString()))
.thenReturn(Single.just(spanIdAttribute.attributeExpression().attribute()));
.thenReturn(Single.just(spanIdAttribute.attributeExpressionAssociation().attribute()));
when(attributeRequestBuilder.buildForAttribute(
spanIdAttribute.attributeExpression().attribute()))
spanIdAttribute.attributeExpressionAssociation().attribute()))
.thenReturn(spanIdAttribute);

doAnswer(
Expand Down Expand Up @@ -91,9 +91,9 @@ void testBuildResponse_spanIdNotRequested() {
Collection<AttributeRequest> attributeRequests = List.of(traceIdAttribute, attributesAttribute);

when(attributeStore.getForeignIdAttribute(any(), anyString(), anyString()))
.thenReturn(Single.just(spanIdAttribute.attributeExpression().attribute()));
.thenReturn(Single.just(spanIdAttribute.attributeExpressionAssociation().attribute()));
when(attributeRequestBuilder.buildForAttribute(
spanIdAttribute.attributeExpression().attribute()))
spanIdAttribute.attributeExpressionAssociation().attribute()))
.thenReturn(spanIdAttribute);

doAnswer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ private Single<Trace> convert(
.map(
attrMap ->
new ConvertedTrace(
attrMap.get(request.idAttribute().attributeExpression().value()).toString(),
attrMap
.get(request.idAttribute().attributeExpressionAssociation().value())
.toString(),
attrMap));
}

Expand Down