Skip to content

Commit

Permalink
Delete dataset version property (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
boddissattva authored Apr 24, 2024
1 parent a7b0bf6 commit 91acce9
Show file tree
Hide file tree
Showing 33 changed files with 161 additions and 226 deletions.
6 changes: 5 additions & 1 deletion chutney/action-impl/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@
<logger name="liquibase" level="WARN"/>
<logger name="LiquibaseSchemaResolver" level="WARN"/>
<logger name="org.apache" level="WARN"/>
<logger name="org.apache.sshd" level="ERROR"/>
<logger name="org.apache.zookeeper" level="ERROR"/>
<logger name="org.apache.maven.surefire.booter" level="WARN"/>
<logger name="org.apache.kafka" level="ERROR"/>
<logger name="kafka" level="ERROR"/>
<logger name="org.eclipse" level="WARN"/>
<logger name="org.hibernate" level="WARN"/>
<logger name="org.mongodb" level="INFO"/>
<logger name="org.mongodb" level="WARN"/>
<logger name="org.jboss" level="WARN"/>
<logger name="qpid" level="WARN"/>
<logger name="org.springframework" level="WARN" />
Expand Down
6 changes: 6 additions & 0 deletions chutney/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@
<version>${jqwik.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.jqwik</groupId>
<artifactId>jqwik-time</artifactId>
<version>${jqwik.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ private DataSetBuilder() {
}

public DataSet build() {
if (!Objects.isNull(id) && id.isEmpty()) {
throw new IllegalArgumentException("Dataset id cannot be empty");
if (ofNullable(id).map(String::isBlank).orElse(false)) {
throw new IllegalArgumentException("Dataset id cannot be blank");
}

return new DataSet(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ interface ExecutionProperties {

Optional<String> datasetId();

Optional<Integer> datasetVersion();

String user();

Optional<CampaignExecution> campaignReport();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class CampaignExecution {
public final boolean partialExecution;
public final String executionEnvironment;
public final Optional<String> dataSetId;
public final Optional<Integer> dataSetVersion;
public final String userId;

// Not mandatory
Expand All @@ -61,7 +60,6 @@ public CampaignExecution(Long executionId,
boolean partialExecution,
String executionEnvironment,
String dataSetId,
Integer dataSetVersion,
String userId) {
this.executionId = executionId;
this.campaignId = null;
Expand All @@ -72,7 +70,6 @@ public CampaignExecution(Long executionId,
this.startDate = now();
this.status = RUNNING;
this.dataSetId = ofNullable(dataSetId);
this.dataSetVersion = ofNullable(dataSetVersion);
this.userId = userId;
}

Expand All @@ -83,7 +80,6 @@ public CampaignExecution(Long executionId,
boolean partialExecution,
String executionEnvironment,
String dataSetId,
Integer dataSetVersion,
String userId) {
this.executionId = executionId;
this.campaignId = campaignId;
Expand All @@ -94,7 +90,6 @@ public CampaignExecution(Long executionId,
this.partialExecution = partialExecution;
this.executionEnvironment = executionEnvironment;
this.dataSetId = ofNullable(dataSetId);
this.dataSetVersion = ofNullable(dataSetVersion);
this.userId = userId;
}

Expand All @@ -106,7 +101,6 @@ public CampaignExecution(Long executionId,
String executionEnvironment,
String userId,
Optional<String> dataSetId,
Optional<Integer> dataSetVersion,
LocalDateTime startDate,
ServerReportStatus status,
List<ScenarioExecutionCampaign> scenarioExecutions
Expand All @@ -117,7 +111,6 @@ public CampaignExecution(Long executionId,
this.partialExecution = partialExecution;
this.executionEnvironment = executionEnvironment;
this.dataSetId = dataSetId;
this.dataSetVersion = dataSetVersion;
this.userId = userId;

if (scenarioExecutions == null) {
Expand Down Expand Up @@ -145,7 +138,6 @@ public void initExecution(List<TestCase> testCases, String executionEnvironment,
.duration(0)
.environment(executionEnvironment)
.datasetId(dataSetId)
.datasetVersion(dataSetVersion)
.user(userId)
.scenarioId(testCase.id())
.build())));
Expand All @@ -167,7 +159,6 @@ public void startScenarioExecution(TestCase testCase, String executionEnvironmen
.duration(0)
.environment(executionEnvironment)
.datasetId(dataSetId)
.datasetVersion(dataSetVersion)
.user(userId)
.scenarioId(testCase.id())
.build()));
Expand Down Expand Up @@ -263,7 +254,6 @@ public CampaignExecution withoutRetries() {
.setCampaignName(campaignName)
.setExecutionEnvironment(executionEnvironment)
.setDataSetId(dataSetId.orElse(null))
.setDataSetVersion(dataSetVersion.orElse(null))
.setUserId(userId)
.setStartDate(startDate)
.setStatus(status)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class CampaignExecutionReportBuilder {
private boolean partialExecution;
private String executionEnvironment;
private String dataSetId;
private Integer dataSetVersion;
private String userId;

// Optional fields
Expand Down Expand Up @@ -82,11 +81,6 @@ public CampaignExecutionReportBuilder setDataSetId(String dataSetId) {
return this;
}

public CampaignExecutionReportBuilder setDataSetVersion(Integer dataSetVersion) {
this.dataSetVersion = dataSetVersion;
return this;
}

public CampaignExecutionReportBuilder setUserId(String userId) {
this.userId = userId;
return this;
Expand Down Expand Up @@ -116,7 +110,6 @@ public CampaignExecution build() {
executionEnvironment,
userId,
ofNullable(dataSetId),
ofNullable(dataSetVersion),
startDate,
status,
scenarioExecutionReports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,37 @@

import java.util.Map;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EmptySource;
import org.junit.jupiter.params.provider.ValueSource;

public class DatasetTest {

@Test
void should_strip_whitespaces_in_name() {
void name_is_stripped() {
String expectedName = "name with spaces";
DataSet actual = DataSet.builder().withName(" name with spaces ").build();
assertThat(actual.name).isEqualTo(expectedName);
}

@Test
public void should_not_have_empty_id() {
void name_is_mandatory() {
assertThatIllegalArgumentException()
.isThrownBy(() -> DataSet.builder().withId("").build())
.withMessage("Dataset id cannot be empty");
.isThrownBy(() -> DataSet.builder().build())
.withMessage("Dataset name mandatory");
}

@ParameterizedTest
@EmptySource
@ValueSource(strings = {" ", " "})
void id_must_not_be_blank(String id) {
assertThatIllegalArgumentException()
.isThrownBy(() -> DataSet.builder().withId(id).build())
.withMessage("Dataset id cannot be blank");
}

@Test
public void should_get_rid_of_empty_keys_and_lines() {
void empty_keys_and_lines_are_ignored() {
// Edge case
DataSet dataSet = DataSet.builder()
.withName("my name")
Expand Down Expand Up @@ -75,7 +87,7 @@ public void should_get_rid_of_empty_keys_and_lines() {
}

@Test
public void should_strip_whitespaces_in_keys_and_values() {
void keys_and_values_are_trimmed() {
Map<String, String> expectedMap = Map.of("key1", "value", "key2", "value");
DataSet dataSet = DataSet.builder()
.withName("my name")
Expand Down
4 changes: 4 additions & 0 deletions chutney/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@
<groupId>net.jqwik</groupId>
<artifactId>jqwik</artifactId>
</dependency>
<dependency>
<groupId>net.jqwik</groupId>
<artifactId>jqwik-time</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import com.chutneytesting.execution.infra.execution.ServerTestEngineJavaImpl;
import com.chutneytesting.jira.api.JiraXrayEmbeddedApi;
import com.chutneytesting.scenario.infra.TestCaseRepositoryAggregator;
import com.chutneytesting.server.core.domain.dataset.DataSetHistoryRepository;
import com.chutneytesting.server.core.domain.execution.ScenarioExecutionEngine;
import com.chutneytesting.server.core.domain.execution.ScenarioExecutionEngineAsync;
import com.chutneytesting.server.core.domain.execution.ServerTestEngine;
Expand All @@ -52,7 +51,6 @@
import com.chutneytesting.tools.ui.MyMixInForIgnoreType;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.json.JsonWriteFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.SerializerProvider;
Expand All @@ -67,7 +65,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.sql.DataSource;
import liquibase.integration.spring.SpringLiquibase;
import org.jdom2.Element;
Expand Down Expand Up @@ -97,7 +94,7 @@ public class ServerConfiguration {

@PostConstruct
public void logPort() throws UnknownHostException {
LOGGER.debug("Starting server " + InetAddress.getLocalHost().getCanonicalHostName() + " on " + port);
LOGGER.debug("Starting server {} on {}", InetAddress.getLocalHost().getCanonicalHostName(), port);
}

/**
Expand Down Expand Up @@ -191,7 +188,6 @@ CampaignExecutionEngine campaignExecutionEngine(CampaignRepository campaignRepos
ScenarioExecutionEngine scenarioExecutionEngine,
ExecutionHistoryRepository executionHistoryRepository,
TestCaseRepositoryAggregator testCaseRepository,
Optional<DataSetHistoryRepository> dataSetHistoryRepository,
JiraXrayEmbeddedApi jiraXrayEmbeddedApi,
ChutneyMetrics metrics,
@Qualifier("campaignExecutor") TaskExecutor campaignExecutor,
Expand All @@ -203,7 +199,6 @@ CampaignExecutionEngine campaignExecutionEngine(CampaignRepository campaignRepos
scenarioExecutionEngine,
executionHistoryRepository,
testCaseRepository,
dataSetHistoryRepository,
jiraXrayEmbeddedApi,
metrics,
new ExecutorServiceAdapter(campaignExecutor),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ public class CampaignExecutionEntity {
@Column(name = "DATASET_ID")
private String datasetId;

@Column(name = "DATASET_VERSION")
private Integer datasetVersion;

@Column(name = "VERSION")
@Version
private Integer version;
Expand All @@ -74,18 +71,17 @@ public CampaignExecutionEntity() {
}

public CampaignExecutionEntity(Long campaignId, String environment) {
this(null, campaignId, null, null, environment, null, null, null, null);
this(null, campaignId, null, null, environment, null, null, null);
}

public CampaignExecutionEntity(Long id, Long campaignId, List<ScenarioExecutionEntity> scenarioExecutions, Boolean partial, String environment, String userId, String datasetId, Integer datasetVersion, Integer version) {
public CampaignExecutionEntity(Long id, Long campaignId, List<ScenarioExecutionEntity> scenarioExecutions, Boolean partial, String environment, String userId, String datasetId, Integer version) {
this.id = id;
this.campaignId = campaignId;
this.scenarioExecutions = scenarioExecutions;
this.partial = ofNullable(partial).orElse(false);
this.environment = environment;
this.userId = userId;
this.datasetId = datasetId;
this.datasetVersion = datasetVersion;
this.version = version;
}

Expand All @@ -110,7 +106,6 @@ public void updateFromDomain(CampaignExecution report, Iterable<ScenarioExecutio
environment = report.executionEnvironment;
userId = report.userId;
datasetId = report.dataSetId.orElse(null);
datasetVersion = report.dataSetVersion.orElse(null);
this.scenarioExecutions.clear();
scenarioExecutions.forEach(se -> {
se.forCampaignExecution(this);
Expand Down Expand Up @@ -149,7 +144,6 @@ public CampaignExecution toDomain(CampaignEntity campaign, boolean withScenarios
ofNullable(partial).orElse(false),
environment,
datasetId,
datasetVersion,
userId);
}

Expand Down
Loading

0 comments on commit 91acce9

Please sign in to comment.