From 14d5671319a68904d383ae16209d757c4651cb02 Mon Sep 17 00:00:00 2001 From: Nizamul Kazi Date: Wed, 1 Nov 2023 21:57:39 -0300 Subject: [PATCH 1/4] Improve Test Coverage - EntityStatColumn, CiCdToolTest, SubGenEventTypeTest --- .../domain/enums/EntityStatColumnTest.java | 19 ++++++++ .../domain/enums/SubGenEventTypeTest.java | 44 +++++++++++++++++++ .../online/service/enums/CiCdToolTest.java | 43 ++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 src/test/java/io/github/jhipster/online/domain/enums/EntityStatColumnTest.java create mode 100644 src/test/java/io/github/jhipster/online/domain/enums/SubGenEventTypeTest.java create mode 100644 src/test/java/io/github/jhipster/online/service/enums/CiCdToolTest.java diff --git a/src/test/java/io/github/jhipster/online/domain/enums/EntityStatColumnTest.java b/src/test/java/io/github/jhipster/online/domain/enums/EntityStatColumnTest.java new file mode 100644 index 00000000..17d28b63 --- /dev/null +++ b/src/test/java/io/github/jhipster/online/domain/enums/EntityStatColumnTest.java @@ -0,0 +1,19 @@ +package io.github.jhipster.online.domain.enums; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class EntityStatColumnTest { + + @Test + public void testGetDatabaseValue() { + assertEquals("fields", EntityStatColumn.FIELDS.getDatabaseValue()); + assertEquals("relationships", EntityStatColumn.RELATIONSHIPS.getDatabaseValue()); + assertEquals("pagination", EntityStatColumn.PAGINATION.getDatabaseValue()); + assertEquals("dto", EntityStatColumn.DTO.getDatabaseValue()); + assertEquals("service", EntityStatColumn.SERVICE.getDatabaseValue()); + assertEquals("fluentMethods", EntityStatColumn.FLUENT_METHODS.getDatabaseValue()); + assertEquals("date", EntityStatColumn.DATE.getDatabaseValue()); + } +} diff --git a/src/test/java/io/github/jhipster/online/domain/enums/SubGenEventTypeTest.java b/src/test/java/io/github/jhipster/online/domain/enums/SubGenEventTypeTest.java new file mode 100644 index 00000000..a6ba66c2 --- /dev/null +++ b/src/test/java/io/github/jhipster/online/domain/enums/SubGenEventTypeTest.java @@ -0,0 +1,44 @@ +package io.github.jhipster.online.domain.enums; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class SubGenEventTypeTest { + + @Test + public void testGetDatabaseValue() { + assertEquals("heroku", SubGenEventType.HEROKU.getDatabaseValue()); + assertEquals("cloudfoundry", SubGenEventType.CLOUDFOUNDRY.getDatabaseValue()); + assertEquals("aws", SubGenEventType.AWS.getDatabaseValue()); + assertEquals("ci-cd", SubGenEventType.CI_CD.getDatabaseValue()); + assertEquals("", SubGenEventType.CLIENT.getDatabaseValue()); + assertEquals("docker-compose", SubGenEventType.DOCKER_COMPOSE.getDatabaseValue()); + assertEquals("export-jdl", SubGenEventType.EXPORT_JDL.getDatabaseValue()); + assertEquals("import-jdl", SubGenEventType.IMPORT_JDL.getDatabaseValue()); + assertEquals("kubernetes", SubGenEventType.KUBERNETES.getDatabaseValue()); + assertEquals("languages", SubGenEventType.LANGUAGES.getDatabaseValue()); + assertEquals("openshift", SubGenEventType.OPENSHIFT.getDatabaseValue()); + assertEquals("rancher-compose", SubGenEventType.RANCHER_COMPOSE.getDatabaseValue()); + assertEquals("server", SubGenEventType.SERVER.getDatabaseValue()); + assertEquals("spring-controller", SubGenEventType.SPRING_CONTROLLER.getDatabaseValue()); + assertEquals("upgrade", SubGenEventType.UPGRADE.getDatabaseValue()); + } + + @Test + public void testGetDeploymentTools() { + SubGenEventType[] deploymentTools = SubGenEventType.getDeploymentTools(); + assertEquals(5, deploymentTools.length); + assertArrayEquals( + new SubGenEventType[] { + SubGenEventType.HEROKU, + SubGenEventType.CLOUDFOUNDRY, + SubGenEventType.AWS, + SubGenEventType.OPENSHIFT, + SubGenEventType.KUBERNETES, + }, + deploymentTools + ); + } +} diff --git a/src/test/java/io/github/jhipster/online/service/enums/CiCdToolTest.java b/src/test/java/io/github/jhipster/online/service/enums/CiCdToolTest.java new file mode 100644 index 00000000..b99259bc --- /dev/null +++ b/src/test/java/io/github/jhipster/online/service/enums/CiCdToolTest.java @@ -0,0 +1,43 @@ +package io.github.jhipster.online.service.enums; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Optional; +import org.junit.jupiter.api.Test; + +public class CiCdToolTest { + + @Test + public void testGetByName() { + Optional ciCdTool = CiCdTool.getByName("TRAVIS"); + assertEquals(CiCdTool.TRAVIS, ciCdTool.orElse(null)); + + ciCdTool = CiCdTool.getByName("JENKINS"); + assertEquals(CiCdTool.JENKINS, ciCdTool.orElse(null)); + + /* testing a CI_CD tool which dont exist */ + ciCdTool = CiCdTool.getByName("UNKNOWN_TOOL"); + assertEquals(Optional.empty(), ciCdTool); + } + + @Test + public void testCommand() { + assertEquals("travis", CiCdTool.TRAVIS.command()); + assertEquals("github", CiCdTool.GITHUB.command()); + assertEquals("circle", CiCdTool.CIRCLE.command()); + } + + @Test + public void testBranchName() { + assertEquals("jhipster-travis-complement", CiCdTool.TRAVIS.branchName("complement")); + assertEquals("jhipster-github-complement", CiCdTool.GITHUB.branchName("complement")); + } + + @Test + public void testGetCiCdToolName() { + assertEquals("GitLab", CiCdTool.GITLAB.getCiCdToolName()); + assertEquals("GitHub", CiCdTool.GITHUB.getCiCdToolName()); + assertEquals("Azure", CiCdTool.AZURE.getCiCdToolName()); + assertEquals("Circle", CiCdTool.CIRCLE.getCiCdToolName()); + } +} From 411728f4ec03cc8dd360cd66afc0b421cfe17be7 Mon Sep 17 00:00:00 2001 From: Kazi Nizamul Date: Thu, 2 Nov 2023 21:27:50 +0000 Subject: [PATCH 2/4] fix: fixed prettier issue --- .../jhipster/online/domain/enums/SubGenEventTypeTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/github/jhipster/online/domain/enums/SubGenEventTypeTest.java b/src/test/java/io/github/jhipster/online/domain/enums/SubGenEventTypeTest.java index a6ba66c2..eb0a3dbc 100644 --- a/src/test/java/io/github/jhipster/online/domain/enums/SubGenEventTypeTest.java +++ b/src/test/java/io/github/jhipster/online/domain/enums/SubGenEventTypeTest.java @@ -36,7 +36,7 @@ public void testGetDeploymentTools() { SubGenEventType.CLOUDFOUNDRY, SubGenEventType.AWS, SubGenEventType.OPENSHIFT, - SubGenEventType.KUBERNETES, + SubGenEventType.KUBERNETES }, deploymentTools ); From dfb24be5e5f59a3a6ed4c249680bb6a5fa03f514 Mon Sep 17 00:00:00 2001 From: Kazi Nizamul Date: Thu, 2 Nov 2023 21:40:26 +0000 Subject: [PATCH 3/4] fix: fixed prettier issue From 10ca0be1e5fb2886e23759f820e20eabe958150e Mon Sep 17 00:00:00 2001 From: Nizamul Kazi Date: Thu, 2 Nov 2023 19:17:08 -0300 Subject: [PATCH 4/4] fix: fixed prettier issue