-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from kintone/chore-refactor-tests
chore: refactor tests of deserializing TimeFieldProperty
- Loading branch information
Showing
6 changed files
with
69 additions
and
30 deletions.
There are no files selected for viewing
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
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
50 changes: 50 additions & 0 deletions
50
src/test/java/com/kintone/client/model/app/field/TimeFieldPropertyTest.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,50 @@ | ||
package com.kintone.client.model.app.field; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
import com.kintone.client.model.record.FieldType; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.time.LocalTime; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class TimeFieldPropertyTest { | ||
private ObjectMapper mapper; | ||
|
||
@BeforeEach | ||
public void setup() { | ||
mapper = new ObjectMapper(); | ||
mapper.registerModule(new JavaTimeModule()); | ||
} | ||
|
||
@Test | ||
public void deserialize() throws IOException { | ||
URL url = getClass().getResource("TimeFieldPropertyTest_deserialize.json"); | ||
|
||
TimeFieldProperty result = mapper.readValue(url, TimeFieldProperty.class); | ||
assertThat(result.getType()).isEqualTo(FieldType.TIME); | ||
assertThat(result.getCode()).isEqualTo("time"); | ||
assertThat(result.getLabel()).isEqualTo("Time field"); | ||
assertThat(result.getNoLabel()).isTrue(); | ||
assertThat(result.getRequired()).isTrue(); | ||
assertThat(result.getDefaultValue()).isEqualTo(LocalTime.of(5, 0)); | ||
assertThat(result.getDefaultNowValue()).isFalse(); | ||
} | ||
|
||
@Test | ||
public void deserialize_defaultValueEmpty() throws IOException { | ||
URL url = getClass().getResource("TimeFieldPropertyTest_deserialize_defaultValueEmpty.json"); | ||
|
||
TimeFieldProperty result = mapper.readValue(url, TimeFieldProperty.class); | ||
assertThat(result.getType()).isEqualTo(FieldType.TIME); | ||
assertThat(result.getCode()).isEqualTo("time"); | ||
assertThat(result.getLabel()).isEqualTo("Time field"); | ||
assertThat(result.getNoLabel()).isFalse(); | ||
assertThat(result.getRequired()).isFalse(); | ||
assertThat(result.getDefaultValue()).isNull(); | ||
assertThat(result.getDefaultNowValue()).isTrue(); | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
.../com/kintone/client/FieldPropertyDeserializerTest_deserialize_TIME_defaultValueEmpty.json
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
src/test/resources/com/kintone/client/model/app/field/TimeFieldPropertyTest_deserialize.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"type": "TIME", | ||
"code": "time", | ||
"label": "Time field", | ||
"noLabel": true, | ||
"required": true, | ||
"defaultValue": "05:00:00.000", | ||
"defaultNowValue": false | ||
} |
9 changes: 9 additions & 0 deletions
9
...m/kintone/client/model/app/field/TimeFieldPropertyTest_deserialize_defaultValueEmpty.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"type": "TIME", | ||
"code": "time", | ||
"label": "Time field", | ||
"noLabel": false, | ||
"required": false, | ||
"defaultValue": "", | ||
"defaultNowValue": true | ||
} |