Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Test Coverage - EntityStatColumn, CiCdToolTest, SubGenEventTypeTest #431

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.github.jhipster.online.domain.enums;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

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,40 @@
package io.github.jhipster.online.domain.enums;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
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,42 @@
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());
}
}