OSDN Git Service

ci: add version test
authorhizumiaoba <56146205+hizumiaoba@users.noreply.github.com>
Wed, 19 Jan 2022 06:30:20 +0000 (15:30 +0900)
committerhizumiaoba <56146205+hizumiaoba@users.noreply.github.com>
Wed, 19 Jan 2022 06:30:20 +0000 (15:30 +0900)
generated/database.json
src/test/VersionTest.java [new file with mode: 0644]

index 469c41d..90df005 100644 (file)
     "level" : 30,
     "notes" : 964,
     "albumType" : "ALBUM C"
+  }, {
+    "attribute" : "キュート",
+    "name" : "cherry*merry*cherry",
+    "difficulty" : "DEBUT",
+    "level" : 8,
+    "notes" : 126,
+    "albumType" : "Not-Implemented"
+  }, {
+    "attribute" : "キュート",
+    "name" : "cherry*merry*cherry",
+    "difficulty" : "REGULAR",
+    "level" : 12,
+    "notes" : 178,
+    "albumType" : "Not-Implemented"
+  }, {
+    "attribute" : "キュート",
+    "name" : "cherry*merry*cherry",
+    "difficulty" : "PRO",
+    "level" : 17,
+    "notes" : 344,
+    "albumType" : "Not-Implemented"
+  }, {
+    "attribute" : "キュート",
+    "name" : "cherry*merry*cherry",
+    "difficulty" : "MASTER",
+    "level" : 25,
+    "notes" : 605,
+    "albumType" : "Not-Implemented"
   } ]
 }
\ No newline at end of file
diff --git a/src/test/VersionTest.java b/src/test/VersionTest.java
new file mode 100644 (file)
index 0000000..c94320b
--- /dev/null
@@ -0,0 +1,34 @@
+package test;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.nio.file.Paths;
+
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.ranfa.lib.CheckVersion;
+
+public class VersionTest {
+       
+       @Test
+       public void matchJSONandAnnotations() {
+               String annotationVersion = CheckVersion.getVersion();
+               int major, minor, patch;
+               major = minor = patch = 0;
+               try {
+                       JsonNode node = new ObjectMapper().readTree(Paths.get("version.json").toFile());
+                       major = node.get("major").asInt();
+                       minor = node.get("minor").asInt();
+                       patch = node.get("patch").asInt();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               String jsonVersion = String.format("v%d.%d.%d", major, minor, patch);
+               // check if json version and annotation version are equal.
+               assertTrue(jsonVersion.equals(annotationVersion));
+       }
+
+}