WIP: updated JSON payload serialization

This commit is contained in:
Claudio Atzori 2024-06-24 14:18:03 +02:00
parent 8658cf9a01
commit ca02fc29b3
2 changed files with 36 additions and 8 deletions

View File

@ -3,8 +3,6 @@ package eu.dnetlib.dhp.schema.solr;
import java.io.Serializable;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Result implements Serializable {
private static final long serialVersionUID = -9121038426985022737L;
@ -147,12 +145,10 @@ public class Result implements Serializable {
*/
private List<EoscIfGuidelines> eoscifguidelines;
@JsonProperty("isGreen")
private Boolean isGreen;
private OpenAccessColor openAccessColor;
@JsonProperty("isInDiamondJournal")
private Boolean isInDiamondJournal;
private Boolean publiclyFunded;
@ -381,11 +377,11 @@ public class Result implements Serializable {
this.eoscifguidelines = eoscifguidelines;
}
public Boolean getGreen() {
public Boolean getIsGreen() {
return isGreen;
}
public void setGreen(Boolean green) {
public void setIsGreen(Boolean green) {
isGreen = green;
}
@ -397,11 +393,11 @@ public class Result implements Serializable {
this.openAccessColor = openAccessColor;
}
public Boolean getInDiamondJournal() {
public Boolean getIsInDiamondJournal() {
return isInDiamondJournal;
}
public void setInDiamondJournal(Boolean inDiamondJournal) {
public void setIsInDiamondJournal(Boolean inDiamondJournal) {
isInDiamondJournal = inDiamondJournal;
}

View File

@ -0,0 +1,32 @@
package eu.dnetlib.dhp.schema.solr;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.*;
public class TestJsonSerialization {
private static ObjectMapper MAPPER = new ObjectMapper();
@Test
void testSerialiseJsonPayload() throws IOException {
Result r = new Result();
r.setIsGreen(true);
r.setIsInDiamondJournal(false);
final String json = MAPPER.writeValueAsString(r);
assertNotNull(json);
System.out.println("json = " + json);
Result r1 = MAPPER.readValue(json, Result.class);
assertTrue(r1.getIsGreen());
assertFalse(r1.getIsInDiamondJournal());
}
}