Skip to content

Commit

Permalink
feat: refactor the object model and covert with unit tests
Browse files Browse the repository at this point in the history
Refs: #312
  • Loading branch information
grigoriev committed Dec 16, 2024
1 parent c57ab6e commit c70814e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.polarion.alm.tracker.model.IBaseline;
import lombok.Data;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
Expand All @@ -17,11 +18,6 @@ public DocumentBaseline(@Nullable String projectBaselineName, @Nullable String d
this.documentBaselineName = documentBaselineName;
}

public DocumentBaseline(@Nullable IBaseline projectBaseline, @Nullable IBaseline moduleBaseline) {
this.projectBaselineName = projectBaseline != null ? projectBaseline.getName() : null;
this.documentBaselineName = moduleBaseline != null ? moduleBaseline.getName() : null;
}

public String asPlaceholder() {
List<String> names = new ArrayList<>();

Expand All @@ -35,4 +31,11 @@ public String asPlaceholder() {

return String.join(" | ", names);
}

public static @NotNull DocumentBaseline from(@Nullable IBaseline projectBaseline, @Nullable IBaseline moduleBaseline) {
String projectBaselineName = projectBaseline != null ? projectBaseline.getName() : null;
String documentBaselineName = moduleBaseline != null ? moduleBaseline.getName() : null;
return new DocumentBaseline(projectBaselineName, documentBaselineName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public abstract class CommonUniqueObjectAdapter implements IUniqueObjectAdapter
IBaseline projectBaseline = baselinesManager.getRevisionBaseline(revision);
IBaseline moduleBaseline = baselinesManager.getRevisionBaseline(getUniqueObject(), revision);

return new DocumentBaseline(projectBaseline, moduleBaseline);
return DocumentBaseline.from(projectBaseline, moduleBaseline);
}

}

0 comments on commit c70814e

Please sign in to comment.