Skip to content

Commit

Permalink
Fix code smells in metadata commands
Browse files Browse the repository at this point in the history
- Rename this constant name to match the regular expression [...]
- Replace these toUpperCase()/toLowerCase() and equals() calls with a single equalsIgnoreCase() call.

Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Sep 19, 2024
1 parent d2dce08 commit 569821d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
/** The list of supported commands for the metadata tool */
public enum MetadataCommands {
/** Migrates items from a source and recreates them on the target cluster */
Migrate,
MIGRATE,

/** Inspects items from a source to determine which can be placed on a target cluster */
Evaluate;
EVALUATE;

public static MetadataCommands fromString(String s) {
for (var command : values()) {
if (command.name().toLowerCase().equals(s.toLowerCase())) {
if (command.name().equalsIgnoreCase(s)) {
return command;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public static void main(String[] args) throws Exception {

var command = Optional.ofNullable(jCommander.getParsedCommand())
.map(MetadataCommands::fromString)
.orElse(MetadataCommands.Migrate);
.orElse(MetadataCommands.MIGRATE);
Result result;
switch (command) {
default:
case Migrate:
case MIGRATE:
if (migrateArgs.help) {
printCommandUsage(jCommander);
return;
Expand All @@ -67,7 +67,7 @@ public static void main(String[] args) throws Exception {
log.info("Starting Metadata Migration");
result = meta.migrate(migrateArgs).execute(context);
break;
case Evaluate:
case EVALUATE:
if (evaluateArgs.help) {
printCommandUsage(jCommander);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class EndToEndTest {

private static Stream<Arguments> scenarios() {
return Stream.of(
Arguments.of(TransferMedium.Http, MetadataCommands.Evaluate),
Arguments.of(TransferMedium.SnapshotImage, MetadataCommands.Migrate),
Arguments.of(TransferMedium.Http, MetadataCommands.Migrate)
Arguments.of(TransferMedium.Http, MetadataCommands.EVALUATE),
Arguments.of(TransferMedium.SnapshotImage, MetadataCommands.MIGRATE),
Arguments.of(TransferMedium.Http, MetadataCommands.MIGRATE)
);
}

Expand Down Expand Up @@ -183,7 +183,7 @@ private void migrateFrom_ES(
var metadata = new MetadataMigration();

MigrationItemResult result;
if (MetadataCommands.Migrate.equals(command)) {
if (MetadataCommands.MIGRATE.equals(command)) {
result = metadata.migrate(arguments).execute(metadataContext);
} else {
result = metadata.evaluate(arguments).execute(metadataContext);
Expand Down Expand Up @@ -223,7 +223,7 @@ private void verifyTargetCluster(
boolean sourceIsES6_8,
TestData testData
) {
var expectUpdatesOnTarget = MetadataCommands.Migrate.equals(command);
var expectUpdatesOnTarget = MetadataCommands.MIGRATE.equals(command);
// If the command was migrate, the target cluster should have the items, if not they
var verifyResponseCode = expectUpdatesOnTarget ? equalTo(200) : equalTo(404);

Expand Down

0 comments on commit 569821d

Please sign in to comment.