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

SUPPORT-29551 add test for a possible class cart exception #757

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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 @@ -6,10 +6,16 @@

import java.util.Collections;

import com.commercetools.api.client.ProjectApiRoot;
import com.commercetools.api.defaultconfig.ApiRootBuilder;
import com.commercetools.api.json.ApiModuleOptions;
import com.commercetools.api.models.cart.*;
import com.commercetools.api.models.type.*;
import commercetools.utils.CommercetoolsTestUtils;

import io.vrap.rmf.base.client.ResponseSerializer;
import io.vrap.rmf.base.client.utils.json.JsonUtils;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -44,4 +50,34 @@ public void updateCartWithCustomFields() {
});
});
}

// https://commercetools.atlassian.net/browse/SUPPORT-29551
@Test
public void fetchCartWithCustomFieldDateTime() {
withType(type -> {
withUpdateableCart(cart -> {
ProjectApiRoot projectApiRoot = ApiRootBuilder.ofEnvironmentVariables()
.withSerializer(ResponseSerializer.of(JsonUtils.createObjectMapper(
ApiModuleOptions.of().withDateAttributeAsString(true).withDateCustomFieldAsString(true))))
.buildProjectRoot();

Cart updatedCart = projectApiRoot.carts()
.update(cart)
.with(b -> b.plus(actionBuilder -> actionBuilder.setCustomTypeBuilder()
.type(type.toResourceIdentifier())
.fields(fieldBuilder -> fieldBuilder.addValue("ttl", "2024-11-11T03:55:48.970653Z"))))
.executeBlocking()
.getBody();

Assertions.assertThat(updatedCart.getCustom().getFields().values())
.isEqualTo(Collections.singletonMap("ttl", "2024-11-11T03:55:48.970653Z"));

Cart fetchedCart = projectApiRoot.carts().withId(cart.getId()).get().executeBlocking().getBody();
Assertions.assertThat(fetchedCart.getCustom().getFields().values())
.isEqualTo(Collections.singletonMap("ttl", "2024-11-11T03:55:48.970653Z"));

return updatedCart;
});
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public static Type createType() {
.label(CommercetoolsTestUtils.randomLocalizedString())
.required(false)
.inputHint(TypeTextInputHint.SINGLE_LINE))
.plusFieldDefinitions(
fieldDefinitionBuilder -> fieldDefinitionBuilder.type(FieldTypeBuilder::dateTimeBuilder)
.name("ttl")
.label(CommercetoolsTestUtils.randomLocalizedString())
.required(false)
.inputHint(TypeTextInputHint.SINGLE_LINE))
.build();

Type type = CommercetoolsTestUtils.getProjectApiRoot().types().post(typeDraft).executeBlocking().getBody();
Expand Down
Loading