Skip to content

Commit

Permalink
Changed the consolidate comic guard name [#889]
Browse files Browse the repository at this point in the history
  • Loading branch information
mcpierce committed Sep 19, 2021
1 parent 1a7b7a8 commit 90c975d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.comixedproject.state.comicbooks.actions.*;
import org.comixedproject.state.comicbooks.guards.ComicContentsProcessedGuard;
import org.comixedproject.state.comicbooks.guards.ComicFileAlreadyRecreatingGuard;
import org.comixedproject.state.comicbooks.guards.ComicFilenameWillChangeGuard;
import org.comixedproject.state.comicbooks.guards.ConsolidateComicGuard;
import org.comixedproject.state.comicbooks.guards.FileDetailsCreatedGuard;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
Expand All @@ -51,7 +51,7 @@ public class ComicStateMachineConfiguration
@Autowired private UpdateMetadataAction updateMetadataAction;
@Autowired private MetadataUpdatedAction metadataUpdatedAction;
@Autowired private ConsolidateComicAction consolidateComicAction;
@Autowired private ComicFilenameWillChangeGuard comicFilenameWillChangeGuard;
@Autowired private ConsolidateComicGuard consolidateComicGuard;
@Autowired private ComicConsolidatedAction comicConsolidatedAction;
@Autowired private ComicFileAlreadyRecreatingGuard comicFileAlreadyRecreatingGuard;
@Autowired private RecreateComicFileAction recreateComicFileAction;
Expand Down Expand Up @@ -137,14 +137,14 @@ public void configure(final StateMachineTransitionConfigurer<ComicState, ComicEv
.source(ComicState.STABLE)
.target(ComicState.STABLE)
.event(ComicEvent.consolidateComic)
.guard(comicFilenameWillChangeGuard)
.guard(consolidateComicGuard)
.action(consolidateComicAction)
.and()
.withExternal()
.source(ComicState.CHANGED)
.target(ComicState.CHANGED)
.event(ComicEvent.consolidateComic)
.guard(comicFilenameWillChangeGuard)
.guard(consolidateComicGuard)
.action(consolidateComicAction)
.and()
.withExternal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
import org.springframework.stereotype.Component;

/**
* <code>ComicFilenameWillChangeGuard</code> checks if the comic already has the target filename.
* <code>ConsolidateComicGuard</code> checks if the comic already has the target filename.
*
* @author Darryl L. Pierce
*/
@Component
@Log4j2
public class ComicFilenameWillChangeGuard extends AbstractComicGuard {
public class ConsolidateComicGuard extends AbstractComicGuard {
@Autowired private ComicFileAdaptor comicFileAdaptor;

@Override
Expand All @@ -53,7 +53,7 @@ public boolean evaluate(final StateContext<ComicState, ComicEvent> context) {
final String renamingRule = context.getMessageHeaders().get(HEADER_RENAMING_RULE, String.class);
log.trace("Generating target name");
final String targetName = this.comicFileAdaptor.createFilenameFromRule(comic, renamingRule);
log.trace("Ensuring the comic filename would be difference");
log.trace("Ensuring the comic filename would be different");
final String absoluteSource = comic.getFile().getAbsolutePath();
final String absoluteTarget =
new File(String.format("%s/%s", targetDirectory, targetName)).getAbsolutePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
import org.springframework.statemachine.StateContext;

@RunWith(MockitoJUnitRunner.class)
public class ComicFilenameWillChangeGuardTest {
public class ConsolidateComicGuardTest {
private static final String TEST_TARGET_DIRECTORY = "/Users/comixed/Documents/old";
private static final String TEST_RENAMING_RULE = "The renaming rule";
private static final String TEST_OLD_FILENAME = "The old filename";
private static final String TEST_NEW_FILENAME = "The new filename";

@InjectMocks private ComicFilenameWillChangeGuard guard;
@InjectMocks private ConsolidateComicGuard guard;
@Mock private StateContext<ComicState, ComicEvent> context;
@Mock private MessageHeaders messageHeaders;
@Mock private Comic comic;
Expand Down

0 comments on commit 90c975d

Please sign in to comment.