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

#49: Missing links in data for streams list #50

Merged
merged 1 commit into from
Oct 25, 2023
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
@@ -1,9 +1,16 @@
package io.github.shinusuresh.productsup.client.domain.streams;

import java.util.List;
import java.util.SortedMap;

/**
* Data object that maps stream response.
*
* @param data - Stream data.
* @param links - Links for pagination.
*/
public record Data(List<Stream> data) {
public record Data(
List<Stream> data,
SortedMap<String, String> links
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@

import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.List;
import java.util.SortedMap;

/**
* Stream response.
*
* @param id - Stream id.
* @param type - Stream type - chunked or referenced
* @param attributes - Stream attributes
* @param links - Links
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public record Stream(String id,
String type,
StreamAttributes attributes,
Relationships relationships,
List<SortedMap<String, String>> links) {
Relationships relationships) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.github.shinusuresh.productsup.client.domain.streams.upload.BatchStageStatus;
import io.github.shinusuresh.productsup.client.domain.streams.upload.UploadAttributes;
import java.util.Map;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.mockserver.client.MockServerClient;
import org.mockserver.junit.jupiter.MockServerSettings;
Expand Down Expand Up @@ -72,13 +73,18 @@ void testListStreams() {
.returns(StreamType.CHUNKED, from((val) -> val.attributes().type()))
.returns("some_string_value", from((val) -> val.relationships().account().accountData().id()))
.returns("account", from((val) -> val.relationships().account().accountData().type()));
}

@Test
@DisplayName("Issue #49")
void testListStreamsLinks() {
assertThat(streamApiClient.listStreams().links()).isNotNull();
}

@Test
void testSuccessCreateStreams() {
var data = new CreateStream(new Stream(null, "stream",
new StreamAttributes("Test Stream", StreamType.CHUNKED, null, null), null, null));
new StreamAttributes("Test Stream", StreamType.CHUNKED, null, null), null));
var createStreamResponse = streamApiClient.createStream(data);
assertThat(createStreamResponse.data().id()).isEqualTo("some_string_value");
}
Expand All @@ -91,7 +97,7 @@ void removeStream() {
@Test
void testUpdateStream() {
var updateStreamRequest = new UpdateStream(new Stream("123", "stream",
new StreamAttributes("Product data stream", null, null, null), null, null));
new StreamAttributes("Product data stream", null, null, null), null));
var updateStreamResponse = streamApiClient.updateStream("83543218", updateStreamRequest);
assertThat(updateStreamResponse.data())
.extracting(Stream::id, Stream::type,
Expand Down Expand Up @@ -147,7 +153,7 @@ void testFailCreateStreams() {
"""
)));
var data = new CreateStream(new Stream(null, "stream",
new StreamAttributes("Test error Stream", StreamType.CHUNKED, null, null), null, null));
new StreamAttributes("Test error Stream", StreamType.CHUNKED, null, null), null));

var exception = assertThrows(WebClientResponseException.class, () -> streamApiClient.createStream(data));
var errors = exception.getResponseBodyAs(StreamErrors.class);
Expand Down
Loading