Skip to content

Commit

Permalink
Add test for TextControlDataDto
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhorridge committed Jul 2, 2024
1 parent 7746420 commit 76fde71
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package edu.stanford.protege.webprotege.forms.data;

import com.fasterxml.jackson.databind.ObjectMapper;
import edu.stanford.protege.webprotege.forms.field.TextControlDescriptor;
import edu.stanford.protege.webprotege.jackson.WebProtegeJacksonApplication;
import org.junit.jupiter.api.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.json.JsonTest;
import org.springframework.boot.test.json.JacksonTester;
import org.springframework.context.annotation.Import;
import uk.ac.manchester.cs.owl.owlapi.OWLLiteralImpl;

import java.io.IOException;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;

@JsonTest
@Import(WebProtegeJacksonApplication.class)
class TextControlDataDtoTest {

@Autowired
private JacksonTester<FormControlDataDto> tester;

@Test
void shouldSerialize() throws IOException {
var data = TextControlDataDto.get(TextControlDescriptor.getDefault(),
new OWLLiteralImpl("Hello", "en", null),
3);
var written = tester.write(data);
System.out.println(written.getJson());
assertThat(written).hasJsonPathValue("control");
assertThat(written).hasJsonPathValue("value");
assertThat(written).hasJsonPathValue("depth");
}
}

0 comments on commit 76fde71

Please sign in to comment.