JooHyukKim commented on code in PR #4790: URL: https://github.com/apache/zeppelin/pull/4790#discussion_r1729149127
########## zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumRegistrySerializerTest.java: ########## @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.zeppelin.helium; + +import org.apache.commons.io.FileUtils; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.UUID; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +class HeliumRegistrySerializerTest { + + private String HELIUM_PACKAGE_JSON_1 = "{\n" + + " \"name\" : \"[organization.A].[name.A]\",\n" + + " \"description\" : \"Description-A\",\n" + + " \"artifact\" : \"groupId:artifactId:version\",\n" + + " \"className\" : \"your.package.name.YourApplicationClass-A\",\n" + + " \"resources\" : [\n" + + " [\"resource.name\", \":resource.class.name\"],\n" + + " [\"alternative.resource.name\", \":alternative.class.name\"]\n" + + " ],\n" + + " \"icon\" : \"<i class='icon'></i>\"\n" + + "}"; + + @Test + void testDeserialization() throws IOException { + // Given + + // When + // Define the output file + Path dir = Files.createDirectory(Paths.get("./" + UUID.randomUUID().toString())); + File newFile = Files.createTempFile(dir, UUID.randomUUID().toString(), ".json").toFile(); + FileUtils.writeStringToFile(newFile, HELIUM_PACKAGE_JSON_1, StandardCharsets.UTF_8); + FileUtils.forceDeleteOnExit(newFile); + + // Write JSON string to file using Apache Commons FileUtils + HeliumRegistry registry = new HeliumLocalRegistry("my-registry", dir.toString()); + + // Then + assertEquals("my-registry", registry.name()); + assertNotNull(registry.getAll()); + assertEquals(1, registry.getAll().size()); + + HeliumPackage heliumPackage = registry.getAll().stream().findFirst().orElseThrow(RuntimeException::new); Review Comment: This is not an action at all, just another value assertion following... ```java assertEquals(1, registry.getAll().size()); ``` But I do think it could be simplified. -- 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: reviews-unsubscr...@zeppelin.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org