eric-maynard commented on code in PR #955: URL: https://github.com/apache/polaris/pull/955#discussion_r1945269016
########## api/management-model/src/test/java/org/apache/polaris/core/admin/model/CatalogSerializationTest.java: ########## @@ -0,0 +1,259 @@ +package org.apache.polaris.core.admin.model; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.DeserializationFeature; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; +import java.util.Collections; +import com.fasterxml.jackson.databind.JsonMappingException; +import java.util.Arrays; + +public class CatalogSerializationTest { + + private ObjectMapper mapper; + private static final String TEST_LOCATION = "s3://test/"; + private static final String TEST_CATALOG_NAME = "test-catalog"; + private static final String TEST_ROLE_ARN = "arn:aws:iam::123456789012:role/test-role"; + + @BeforeEach + public void setUp() { + mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + @Test + public void testCatalogSerialization() throws JsonProcessingException { + CatalogProperties properties = new CatalogProperties(TEST_LOCATION); + + StorageConfigInfo storageConfig = new StorageConfigInfo( + StorageConfigInfo.StorageTypeEnum.S3, + Collections.emptyList()); + + Catalog catalog = new Catalog( + Catalog.TypeEnum.INTERNAL, + TEST_CATALOG_NAME, + properties, + storageConfig); + + String json = mapper.writeValueAsString(catalog); + JsonNode jsonNode = mapper.readTree(json); + + assertEquals(1, countTypeFields(jsonNode)); + assertEquals("INTERNAL", jsonNode.get("type").asText()); + } + + @Test + public void testCatalogDeserialization() throws JsonProcessingException { + String json = "{" + + "\"type\": \"INTERNAL\"," Review Comment: This format seems much better than the repeated `append` calls below -- and block quotes would probably be even better. Can you try to use this format, or block quotes, below? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org