Skip to content

Commit

Permalink
Merge pull request #433 from KaziNizamul/main
Browse files Browse the repository at this point in the history
Improve Test Coverage - EntityStatColumn, CiCdToolTest, SubGenEventTypeTest
  • Loading branch information
DanielFran authored Nov 7, 2023
2 parents 28cd570 + 10ca0be commit eec2d53
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
@@ -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
);
}
}
Original file line number Diff line number Diff line change
@@ -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 = 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());
}
}

0 comments on commit eec2d53

Please sign in to comment.