-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed test that should have required presence of a field in JSON but …
…no value
- Loading branch information
1 parent
31f47df
commit 0258e29
Showing
2 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/test/java/edu/stanford/protege/webprotege/forms/data/GridControlDataDtoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package edu.stanford.protege.webprotege.forms.data; | ||
|
||
import com.google.common.collect.*; | ||
import edu.stanford.protege.webprotege.common.Page; | ||
import edu.stanford.protege.webprotege.forms.FilterState; | ||
import edu.stanford.protege.webprotege.forms.field.GridControlDescriptor; | ||
import edu.stanford.protege.webprotege.jackson.WebProtegeJacksonApplication; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.json.*; | ||
import org.springframework.boot.test.json.JacksonTester; | ||
import org.springframework.context.annotation.Import; | ||
|
||
import java.io.*; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* Matthew Horridge | ||
* Stanford Center for Biomedical Informatics Research | ||
* 2024-07-03 | ||
*/ | ||
@JsonTest | ||
@AutoConfigureJsonTesters | ||
@Import(WebProtegeJacksonApplication.class) | ||
public class GridControlDataDtoTest { | ||
|
||
@Autowired | ||
private JacksonTester<FormControlDataDto> tester; | ||
|
||
|
||
@Test | ||
void shouldSerialize() throws IOException { | ||
var data = GridControlDataDto.get(GridControlDescriptor.get(ImmutableList.of(), null), Page.emptyPage(), | ||
ImmutableSet.of(), | ||
3, | ||
FilterState.FILTERED); | ||
var written = tester.write(data); | ||
System.out.println(written.getJson()); | ||
assertThat(written).hasJsonPathStringValue("['@type']", "GridControlDataDto"); | ||
assertThat(written).hasJsonPathValue("control"); | ||
assertThat(written).hasJsonPathValue("rows"); | ||
assertThat(written).hasJsonPathValue("ordering"); | ||
assertThat(written).hasJsonPathValue("depth"); | ||
assertThat(written).hasJsonPathValue("filterState"); | ||
} | ||
|
||
@Test | ||
void shouldDeserialize() throws IOException { | ||
var json = """ | ||
{"@type":"GridControlDataDto","depth":3,"control":{"@type":"GRID","columns":[],"subjectFactory":null},"rows":{"pageElements":[],"pageSize":0,"totalElements":0,"pageNumber":1,"pageCount":1},"ordering":[],"filterState":"FILTERED"} | ||
"""; | ||
tester.read(new StringReader(json)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters