Skip to content
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

Remove kendra dependency #439

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,6 @@
<artifactId>s3</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>kendra</artifactId>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ public void invokeHandler_CompleteSynchronously_returnsSuccess(final String requ
@Test
public void invokeHandler_DependenciesInitialised_CompleteSynchronously_returnsSuccess() throws IOException {
lenient().when(cipher.decryptCredentials(any())).thenReturn(new Credentials("123", "123", "123"));
final HookWrapperOverride wrapper = new HookWrapperOverride(platformEventsLogger, cipher);

// if the handler responds Complete, this is treated as a successful synchronous
// completion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ public void invokeHandler_CompleteSynchronously_returnsSuccess(final String requ

@Test
public void invokeHandler_DependenciesInitialised_CompleteSynchronously_returnsSuccess() throws IOException {
final WrapperOverride wrapper = new WrapperOverride(platformEventsLogger);
final TestModel model = new TestModel();

// if the handler responds Complete, this is treated as a successful synchronous
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
import software.amazon.awssdk.services.cloudwatchevents.model.PutTargetsResultEntry;
import software.amazon.awssdk.services.cloudwatchevents.model.Tag;
import software.amazon.awssdk.services.cloudwatchevents.model.Target;
import software.amazon.awssdk.services.kendra.model.DataSourceConfiguration;
import software.amazon.awssdk.services.kendra.model.TemplateConfiguration;
import software.amazon.awssdk.services.kendra.model.UpdateDataSourceRequest;
import software.amazon.awssdk.utils.builder.SdkBuilder;
import software.amazon.cloudformation.resource.Serializer;

Expand Down Expand Up @@ -437,30 +434,78 @@ public void typeMismatchError() {
assertThat(exception.getMessage()).contains("Type mismatch, expecting " + MarshallingType.MAP + " got List type");
}

@lombok.EqualsAndHashCode
@lombok.ToString
@lombok.Getter
private static class PojoContainingDocument implements SdkPojo {

private final Document document;

private static final SdkField<Document> DOCUMENT_VALUE_FIELD = SdkField.builder(MarshallingType.DOCUMENT)
.getter(documentGetter(PojoContainingDocument::getDocument))
.setter(documentSetter(PojoContainingDocument.Builder::documentValue))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DocumentValue").build()).build();
private static final List<SdkField<?>> SDK_FIELDS = Collections.singletonList(DOCUMENT_VALUE_FIELD);

@Override
public List<SdkField<?>> sdkFields() {
return SDK_FIELDS;
}

public static PojoContainingDocument.Builder builder() {
return new PojoContainingDocument.Builder();
}

private PojoContainingDocument(Builder builder) {
this.document = builder.documentValue;
}

public static class Builder implements SdkBuilder<PojoContainingDocument.Builder, PojoContainingDocument>, SdkPojo {

private Document documentValue;

public PojoContainingDocument.Builder documentValue(Document documentValue) {
this.documentValue = documentValue;
return this;
}

Builder() {
}

@Override
public PojoContainingDocument build() {
return new PojoContainingDocument(this);
}

@Override
public List<SdkField<?>> sdkFields() {
return SDK_FIELDS;
}
}

// static wrappers of getDocument & putDocument
private static Function<Object, Document> documentGetter(Function<PojoContainingDocument, Document> g) {
return obj -> g.apply((PojoContainingDocument) obj);
}

private static BiConsumer<Object, Document> documentSetter(BiConsumer<PojoContainingDocument.Builder, Document> s) {
return (obj, val) -> s.accept((PojoContainingDocument.Builder) obj, val);
}
}

@Test
public void documentFieldSerde() throws Exception {
Document template = Document.mapBuilder().putString("type", "S3")
.putDocument("connectionConfiguration",
public void testDocumentFieldSerde() throws Exception {
Document template = Document.mapBuilder().putString("type", "Foo")
.putDocument("fooConfigurationDocument1",
Document.mapBuilder()
.putDocument("repositoryEndpointMetadata", Document.mapBuilder().putString("BucketName", "mybucket").build())
.putDocument("fooConfigurationDocumentNestedData", Document.mapBuilder().putString("name", "value").build())
.build())
.putDocument("repositoryConfigurations",
Document.mapBuilder()
.putDocument("document",
Document.mapBuilder().putDocument("fieldMappings", Document.listBuilder()
.addDocument(Document.mapBuilder().putString("indexFieldName", "foo")
.putString("indexFieldType", "STRING").putString("dataSourceFieldName", "foo").build())
.build()).build())
.build())
.putBoolean("booleanValue", false).putNumber("numberValue", 1).putNull("nullValue").build();
UpdateDataSourceRequest request = UpdateDataSourceRequest.builder()
.configuration(DataSourceConfiguration.builder()
.templateConfiguration(TemplateConfiguration.builder().template(template).build()).build())
.id("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").indexId("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").build();

String json = serializer.serialize(request);
UpdateDataSourceRequest deserialized = serializer.deserialize(json, new TypeReference<UpdateDataSourceRequest>() {
.putDocument("fooConfigurationDocument2", Document.mapBuilder().putNumber("numberField1", 0.1).build())
.putBoolean("booleanField1", false).putNumber("numberField2", 10).build();
PojoContainingDocument pojoContainingDocument = PojoContainingDocument.builder().documentValue(template).build();
String json = serializer.serialize(pojoContainingDocument);
PojoContainingDocument deserialized = serializer.deserialize(json, new TypeReference<PojoContainingDocument>() {
});
assertThat(deserialized).isEqualTo(request);
assertThat(deserialized).isEqualTo(pojoContainingDocument);
}
}
Loading