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

Change type for Calc Fields from BigDecimal to String #34

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
3 changes: 1 addition & 2 deletions src/main/java/com/kintone/client/RecordDeserializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ private FieldValue deserialize(FieldType fieldType, JsonNode node) {
switch (fieldType) {
case CALC:
{
BigDecimal value = convertValue(node, BigDecimal::new);
return new CalcFieldValue(value);
return new CalcFieldValue(node.textValue());
}
case CATEGORY:
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class CalcFieldValue implements FieldValue {

/** The value of the Calculated field. */
private final BigDecimal value;
private final String value;

/** {@inheritDoc} */
@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/kintone/client/model/record/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public List<String> getCheckBoxFieldValue(String fieldCode) {
* @param fieldCode the field code
* @return the value of the field
*/
public BigDecimal getCalcFieldValue(String fieldCode) {
public String getCalcFieldValue(String fieldCode) {
CalcFieldValue value = (CalcFieldValue) fields.get(fieldCode);
return value == null ? null : value.getValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public List<String> getCheckBoxFieldValue(String fieldCode) {
* @param fieldCode the field code
* @return the value of the field
*/
public BigDecimal getCalcFieldValue(String fieldCode) {
public String getCalcFieldValue(String fieldCode) {
CalcFieldValue value = (CalcFieldValue) fields.get(fieldCode);
return value == null ? null : value.getValue();
}
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/com/kintone/client/RecordDeserializerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ public void deserialize_fields() throws IOException {
.setFileKey("key");
ZonedDateTime dateTime = ZonedDateTime.of(2020, 1, 2, 3, 4, 0, 0, ZoneOffset.UTC);

assertThat(record.getFieldCodes(true)).hasSize(18);
assertThat(record.getFieldValue("calc")).isEqualTo(new CalcFieldValue(new BigDecimal(100)));
assertThat(record.getFieldCodes(true)).hasSize(19);
assertThat(record.getFieldValue("calc")).isEqualTo(new CalcFieldValue("100"));
assertThat(record.getFieldValue("date_calc")).isEqualTo(new CalcFieldValue("2020-01-01"));
assertThat(record.getFieldValue("check_box"))
.isEqualTo(new CheckBoxFieldValue("option 1", "option 2"));
assertThat(record.getFieldValue("date"))
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/kintone/client/RecordSerializerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void serialize_emptyRecord() throws IOException {

@Test
public void serialize_CALC() throws IOException {
Record record = new Record().putField("calc", new CalcFieldValue(new BigDecimal(100)));
Record record = new Record().putField("calc", new CalcFieldValue("100"));
String json = mapper.writeValueAsString(record);
assertThat(json).isEqualTo("{}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"type": "CALC",
"value": "100"
},
"date_calc": {
"type": "CALC",
"value": "2020-01-01"
},
"check_box": {
"type": "CHECK_BOX",
"value": [
Expand Down