Skip to content
Merged
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
Expand Up @@ -34,6 +34,7 @@
import io.flamingock.internal.core.pipeline.execution.ExecutableStage;
import io.flamingock.internal.core.pipeline.loaded.stage.AbstractLoadedStage;
import io.flamingock.internal.common.core.task.TaskDescriptor;
import io.flamingock.internal.core.task.loaded.AbstractLoadedTask;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand Down Expand Up @@ -66,7 +67,7 @@ public static ExecutionPlanRequest toRequest(List<AbstractLoadedStage> loadedSta
return new ExecutionPlanRequest(lockAcquiredForMillis, requestStages);
}

private static TaskRequest mapToTaskRequest(TaskDescriptor descriptor,
private static TaskRequest mapToTaskRequest(AbstractLoadedTask descriptor,
Map<String, TargetSystemAuditMarkType> ongoingStatusesMap) {
if (ongoingStatusesMap.containsKey(descriptor.getId())) {
if (ongoingStatusesMap.get(descriptor.getId()) == TargetSystemAuditMarkType.ROLLBACK) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AbstractPreviewTask(String id,
String author,
String source,
boolean runAlways,
boolean transactional,
Boolean transactional,
boolean system,
TargetSystemDescriptor targetSystem,
RecoveryDescriptor recovery,
Expand All @@ -60,7 +60,7 @@ public String toString() {
", order='" + order + '\'' +
", source='" + source + '\'' +
", runAlways=" + runAlways +
", transactional=" + transactional +
", transactionalFlag=" + transactionalFlag +
", targetSystem='" + (getTargetSystem() != null ? getTargetSystem().getId() : null) + '\'' +
", recovery='" + (getRecovery() != null ? getRecovery().getStrategy() : null) + '\'' +
'}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public CodePreviewChange(String id,
PreviewMethod applyPreviewMethod,
PreviewMethod rollbackPreviewMethod,
boolean runAlways,
boolean transactional,
Boolean transactional,
boolean system,
TargetSystemDescriptor targetSystem,
RecoveryDescriptor recovery,
Expand Down Expand Up @@ -93,7 +93,7 @@ public String toString() {
", author='" + author + '\'' +
", source='" + source + '\'' +
", runAlways=" + runAlways +
", transactional=" + transactional +
", transactionalFlag=" + transactionalFlag +
(getTargetSystem() != null ? ", targetSystem='" + getTargetSystem().getId() + '\'' : "") +
(getRecovery() != null ? ", recovery='" + getRecovery().getStrategy() + '\'' : "") +
'}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public TemplatePreviewChange(String fileName,
String author,
String templateName,
List<String> profiles,
boolean transactional,
Boolean transactional,
boolean runAlways,
boolean system,
Object configuration,
Expand Down Expand Up @@ -121,7 +121,7 @@ public String toString() {
", author='" + author + '\'' +
", source='" + source + '\'' +
", runAlways=" + runAlways +
", transactional=" + transactional +
", transactionalFlag=" + transactionalFlag +
", system=" + system +
", targetSystem='" + (getTargetSystem() != null ? getTargetSystem().getId() : null) + '\'' +
", recovery='" + (getRecovery() != null ? getRecovery().getStrategy() : null) + '\'' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class CodePreviewTaskBuilder implements PreviewTaskBuilder<CodePreviewCha
private PreviewMethod applyMethod;
private PreviewMethod rollbackMethod;
private boolean runAlways = false;
private boolean transactional;
private Boolean transactionalFlag;
private boolean system;
private TargetSystemDescriptor targetSystem;
private RecoveryDescriptor recovery;
Expand Down Expand Up @@ -116,8 +116,8 @@ public CodePreviewTaskBuilder setRunAlways(boolean runAlways) {
return this;
}

public CodePreviewTaskBuilder setTransactional(boolean transactional) {
this.transactional = transactional;
public CodePreviewTaskBuilder setTransactionalFlag(Boolean transactionalFlag) {
this.transactionalFlag = transactionalFlag;
return this;
}

Expand All @@ -143,7 +143,7 @@ CodePreviewTaskBuilder setTypeElement(TypeElement typeElement) {
setApplyMethod(getAnnotatedMethodInfo(typeElement, Apply.class).orElse(null));
setRollbackMethod(getAnnotatedMethodInfo(typeElement, Rollback.class).orElse(null));
setRunAlways(false); //TODO: how to set runAlways
setTransactional(changeAnnotation.transactional());
setTransactionalFlag(changeAnnotation.transactional());
setSystem(false);
}
if(targetSystemAnnotation != null) {
Expand Down Expand Up @@ -175,7 +175,7 @@ private CodePreviewChange getCodePreviewChange() {
applyMethod,
rollbackMethod,
runAlways,
transactional,
transactionalFlag,
system,
targetSystem,
recovery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TemplatePreviewTaskBuilder implements PreviewTaskBuilder<TemplatePreviewCh
private String templateClassPath;
private String profilesString;
private boolean runAlways;
private Boolean transactional;
private Boolean transactionalFlag;
private Object configuration;
private Object apply;
private Object rollback;
Expand Down Expand Up @@ -84,8 +84,8 @@ public TemplatePreviewTaskBuilder setRunAlways(boolean runAlways) {
return this;
}

public TemplatePreviewTaskBuilder setTransactional(Boolean transactional) {
this.transactional = transactional;
public TemplatePreviewTaskBuilder setTransactionalFlag(Boolean transactionalFlag) {
this.transactionalFlag = transactionalFlag;
return this;
}

Expand Down Expand Up @@ -126,7 +126,7 @@ public TemplatePreviewChange build() {
author,
templateClassPath,
profiles,
transactional,
transactionalFlag,
runAlways,
false,
configuration,
Expand Down Expand Up @@ -160,7 +160,7 @@ TemplatePreviewTaskBuilder setFromDefinition(ChangeTemplateFileContent templateT
setApply(templateTaskDescriptor.getApply());
setRollback(templateTaskDescriptor.getRollback());
setSteps(templateTaskDescriptor.getSteps());
setTransactional(templateTaskDescriptor.getTransactional() != null ? templateTaskDescriptor.getTransactional() : true);
setTransactionalFlag(templateTaskDescriptor.getTransactional());
setRunAlways(false);
setTargetSystem(templateTaskDescriptor.getTargetSystem());
setRecovery(templateTaskDescriptor.getRecovery() != null ? templateTaskDescriptor.getRecovery() : RecoveryDescriptor.getDefault());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract class AbstractTaskDescriptor implements TaskDescriptor {

protected boolean runAlways;

protected boolean transactional;
protected Boolean transactionalFlag;

protected boolean system;

Expand All @@ -48,7 +48,7 @@ public AbstractTaskDescriptor(String id,
String author,
String source,
boolean runAlways,
boolean transactional,
Boolean transactionalFlag,
boolean system,
TargetSystemDescriptor targetSystem,
RecoveryDescriptor recovery,
Expand All @@ -58,7 +58,7 @@ public AbstractTaskDescriptor(String id,
this.author = author;
this.source = source;
this.runAlways = runAlways;
this.transactional = transactional;
this.transactionalFlag = transactionalFlag;
this.system = system;
this.targetSystem = targetSystem;
this.recovery = recovery;
Expand Down Expand Up @@ -91,8 +91,8 @@ public boolean isRunAlways() {
}

@Override
public boolean isTransactional() {
return transactional;
public Optional<Boolean> getTransactionalFlag() {
return Optional.ofNullable(transactionalFlag);
}

@Override
Expand Down Expand Up @@ -135,8 +135,8 @@ public void setRunAlways(boolean runAlways) {
this.runAlways = runAlways;
}

public void setTransactional(boolean transactional) {
this.transactional = transactional;
public void setTransactionalFlag(Boolean transactionalFlag) {
this.transactionalFlag = transactionalFlag;
}

public void setSystem(boolean system) {
Expand Down Expand Up @@ -179,7 +179,7 @@ public String toString() {
.add("id='" + getId() + "'")
.add("author='" + getAuthor() + "'")
.add("runAlways=" + isRunAlways())
.add("transactional=" + isTransactional())
.add("transactionalFlag=" + transactionalFlag)
.add("order=" + getOrder())
.add("sortable=" + isSortable())
.add("targetSystem=" + targetSystem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface TaskDescriptor extends Comparable<TaskDescriptor> {

boolean isRunAlways();

boolean isTransactional();
Optional<Boolean> getTransactionalFlag();

boolean isSystem();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright 2026 Flamingock (https://www.flamingock.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.flamingock.internal.common.core.preview.builder;

import io.flamingock.internal.common.core.preview.TemplatePreviewChange;
import io.flamingock.internal.common.core.task.TargetSystemDescriptor;
import io.flamingock.internal.common.core.template.ChangeTemplateFileContent;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Optional;

import static org.junit.jupiter.api.Assertions.*;

@DisplayName("TemplatePreviewTaskBuilder transactional nullable support")
class TemplatePreviewTaskBuilderTest {

@Test
@DisplayName("Should preserve null transactional from YAML")
void shouldPreserveNullTransactionalFromYaml() {
ChangeTemplateFileContent content = new ChangeTemplateFileContent(
"test-id", "author", "SqlTemplate", null,
null, null, "CREATE TABLE", null,
TargetSystemDescriptor.fromId("postgresql"), null);

TemplatePreviewChange preview = TemplatePreviewTaskBuilder.builder(content)
.setFileName("_0001__test.yaml")
.build();

assertEquals(Optional.empty(), preview.getTransactionalFlag());
}

@Test
@DisplayName("Should preserve explicit true transactional from YAML")
void shouldPreserveExplicitTrueTransactional() {
ChangeTemplateFileContent content = new ChangeTemplateFileContent(
"test-id", "author", "SqlTemplate", null,
true, null, "CREATE TABLE", null,
TargetSystemDescriptor.fromId("postgresql"), null);

TemplatePreviewChange preview = TemplatePreviewTaskBuilder.builder(content)
.setFileName("_0001__test.yaml")
.build();

assertEquals(Optional.of(true), preview.getTransactionalFlag());
}

@Test
@DisplayName("Should preserve explicit false transactional from YAML")
void shouldPreserveExplicitFalseTransactional() {
ChangeTemplateFileContent content = new ChangeTemplateFileContent(
"test-id", "author", "SqlTemplate", null,
false, null, "CREATE TABLE", null,
TargetSystemDescriptor.fromId("postgresql"), null);

TemplatePreviewChange preview = TemplatePreviewTaskBuilder.builder(content)
.setFileName("_0001__test.yaml")
.build();

assertEquals(Optional.of(false), preview.getTransactionalFlag());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright 2026 Flamingock (https://www.flamingock.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.flamingock.internal.common.core.task;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Optional;

import static org.junit.jupiter.api.Assertions.*;

@DisplayName("AbstractTaskDescriptor transactional nullable support")
class AbstractTaskDescriptorTest {

private static AbstractTaskDescriptor createDescriptor(Boolean transactional) {
return new AbstractTaskDescriptor(
"test-id", "001", "author", "source",
false, transactional, false,
null, null, false
) {};
}

@Test
@DisplayName("getTransactionalFlag() returns empty when field is null")
void getTransactionalReturnsEmptyWhenNull() {
AbstractTaskDescriptor descriptor = createDescriptor(null);
assertEquals(Optional.empty(), descriptor.getTransactionalFlag());
}

@Test
@DisplayName("getTransactionalFlag() returns Optional.of(true) when field is true")
void getTransactionalReturnsPresentWhenTrue() {
AbstractTaskDescriptor descriptor = createDescriptor(true);
assertEquals(Optional.of(true), descriptor.getTransactionalFlag());
}

@Test
@DisplayName("getTransactionalFlag() returns Optional.of(false) when field is false")
void getTransactionalReturnsPresentWhenFalse() {
AbstractTaskDescriptor descriptor = createDescriptor(false);
assertEquals(Optional.of(false), descriptor.getTransactionalFlag());
}

@Test
@DisplayName("setTransactionalFlag() accepts null")
void setTransactionalFlagAcceptsNull() {
AbstractTaskDescriptor descriptor = createDescriptor(true);
descriptor.setTransactionalFlag(null);
assertEquals(Optional.empty(), descriptor.getTransactionalFlag());
}

@Test
@DisplayName("toString() handles null transactional without throwing")
void toStringHandlesNullTransactional() {
AbstractTaskDescriptor descriptor = createDescriptor(null);
assertDoesNotThrow(() -> descriptor.toString());
assertTrue(descriptor.toString().contains("transactionalFlag=null"));
}
}
Loading
Loading