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

chore: refactor tests of deserializing TimeFieldProperty #57

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading