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

[OPIK-121] Allow multiline in dataset description #339

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class ValidationUtils {

public static final String NULL_OR_NOT_BLANK = "^(?!\\s*$).+";
public static final String NULL_OR_NOT_BLANK = "(?s)^\\s*(\\S.*\\S|\\S)\\s*$";
andrescrz marked this conversation as resolved.
Show resolved Hide resolved

/**
* Canonical String representation to ensure precision over float or double.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,22 @@ void create__success() {
createAndAssert(dataset);
}

@Test
@DisplayName("when description is multiline, then accept the request")
void create__whenDescriptionIsMultiline__thenAcceptTheRequest() {

var dataset = factory.manufacturePojo(Dataset.class).toBuilder()
.id(null)
.description("""
Test
Description
"""
)
.build();

createAndAssert(dataset);
}

@Test
@DisplayName("when creating datasets with same name in different workspaces, then accept the request")
void create__whenCreatingDatasetsWithSameNameInDifferentWorkspaces__thenAcceptTheRequest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,30 @@ void create__whenWorkspaceNameIsSpecified__thenAcceptTheRequest() {
assertProject(project.toBuilder().id(id).build(), apiKey, workspaceName);
}

@Test
@DisplayName("when workspace description is multiline, then accept the request")
void create__whenDescriptionIsMultiline__thenAcceptTheRequest() {
var project = factory.manufacturePojo(Project.class);

project = project.toBuilder().description("Test Project\n\nMultiline Description").build();

UUID id;
try (var actualResponse = client.target(URL_TEMPLATE.formatted(baseURI)).request()
.accept(MediaType.APPLICATION_JSON_TYPE)
.header(HttpHeaders.AUTHORIZATION, API_KEY)
.header(WORKSPACE_HEADER, TEST_WORKSPACE)
.post(Entity.json(project))) {

assertThat(actualResponse.getStatusInfo().getStatusCode()).isEqualTo(201);
assertThat(actualResponse.hasEntity()).isFalse();
assertThat(actualResponse.getHeaderString("Location")).matches(Pattern.compile(URL_PATTERN));

id = TestUtils.getIdFromLocation(actualResponse.getLocation());
}

assertProject(project.toBuilder().id(id).build());
}

@Test
@DisplayName("when description is null, then accept the request")
void create__whenDescriptionIsNull__thenAcceptNameCreate() {
Expand Down