Skip to content

Commit

Permalink
Merge pull request #57 from kintone/chore-refactor-tests
Browse files Browse the repository at this point in the history
chore: refactor tests of deserializing TimeFieldProperty
  • Loading branch information
0gr authored Jul 3, 2024
2 parents 07ee7a4 + feac98e commit ca453e2
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 30 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,4 @@ Cybozu, Inc.
## Contributors

- AaronJRubin [@AaronJRubin](https://github.com/AaronJRubin)
- chikamura [@chikamura](https://github.com/chikamura)
Original file line number Diff line number Diff line change
Expand Up @@ -597,25 +597,6 @@ public void deserialize_TIME() throws IOException {
assertThat(obj.getDefaultNowValue()).isFalse();
}

@Test
public void deserialize_TIME_defaultValueEmpty() throws IOException {
URL url =
getClass()
.getResource("FieldPropertyDeserializerTest_deserialize_TIME_defaultValueEmpty.json");

TestObject result = mapper.readValue(url, TestObject.class);
assertThat(result.getProperty()).isInstanceOf(TimeFieldProperty.class);

TimeFieldProperty obj = (TimeFieldProperty) result.getProperty();
assertThat(obj.getType()).isEqualTo(FieldType.TIME);
assertThat(obj.getCode()).isEqualTo("time");
assertThat(obj.getLabel()).isEqualTo("Time field");
assertThat(obj.getNoLabel()).isFalse();
assertThat(obj.getRequired()).isFalse();
assertThat(obj.getDefaultValue()).isNull();
assertThat(obj.getDefaultNowValue()).isTrue();
}

@Test
public void deserialize_UPDATED_TIME() throws IOException {
URL url = getClass().getResource("FieldPropertyDeserializerTest_deserialize_UPDATED_TIME.json");
Expand Down
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();
}
}

This file was deleted.

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
}
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
}

0 comments on commit ca453e2

Please sign in to comment.