From 5063ab12c48a6612d903c44c943230b6c323f602 Mon Sep 17 00:00:00 2001 From: Keuin Date: Sun, 24 Jan 2021 20:01:17 +0800 Subject: Code refactor: eliminate unnecessary instance creation of IncrementalBackupFileNameEncoder --- .../incremental/serializer/IncBakupBackwardCompatibilityTest.java | 2 +- .../backup/name/IncrementalBackupFileNameEncoderTest.java | 6 +++--- .../backup/method/ConfiguredIncrementalBackupMethodTest.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBakupBackwardCompatibilityTest.java b/src/test/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBakupBackwardCompatibilityTest.java index d50b264..3de75b9 100644 --- a/src/test/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBakupBackwardCompatibilityTest.java +++ b/src/test/java/com/keuin/kbackupfabric/backup/incremental/serializer/IncBakupBackwardCompatibilityTest.java @@ -22,7 +22,7 @@ public class IncBakupBackwardCompatibilityTest { private final LocalDateTime backupTime = LocalDateTime.of(2000, 1, 1, 1, 1, 1, 1); private final Path testRoot = Paths.get(".\\testfile\\IncBackupBackwardCompatibilityTest"); - private final File indexFile = new File(testRoot.toString(), new IncrementalBackupFileNameEncoder().encode(customName, backupTime)); + private final File indexFile = new File(testRoot.toString(), IncrementalBackupFileNameEncoder.INSTANCE.encode(customName, backupTime)); @Test public void testBackwardCompatibility() throws IOException { diff --git a/src/test/java/com/keuin/kbackupfabric/backup/name/IncrementalBackupFileNameEncoderTest.java b/src/test/java/com/keuin/kbackupfabric/backup/name/IncrementalBackupFileNameEncoderTest.java index f9695d5..0576c3e 100644 --- a/src/test/java/com/keuin/kbackupfabric/backup/name/IncrementalBackupFileNameEncoderTest.java +++ b/src/test/java/com/keuin/kbackupfabric/backup/name/IncrementalBackupFileNameEncoderTest.java @@ -11,7 +11,7 @@ public class IncrementalBackupFileNameEncoderTest { public void testEncode() { LocalDateTime time = LocalDateTime.of(1, 1, 1, 1, 1, 1); String customName = "name"; - IncrementalBackupFileNameEncoder encoder = new IncrementalBackupFileNameEncoder(); + IncrementalBackupFileNameEncoder encoder = IncrementalBackupFileNameEncoder.INSTANCE; assertEquals("incremental-0001-01-01_01-01-01_name.kbi", encoder.encode(customName, time)); } @@ -19,7 +19,7 @@ public class IncrementalBackupFileNameEncoderTest { public void testDecode() { LocalDateTime time = LocalDateTime.of(1, 1, 1, 1, 1, 1); String customName = "name"; - IncrementalBackupFileNameEncoder encoder = new IncrementalBackupFileNameEncoder(); + IncrementalBackupFileNameEncoder encoder = IncrementalBackupFileNameEncoder.INSTANCE; BackupFileNameEncoder.BackupBasicInformation information = encoder.decode("incremental-0001-01-01_01-01-01_name.kbi"); assertEquals(time, information.time); assertEquals(customName, information.customName); @@ -27,7 +27,7 @@ public class IncrementalBackupFileNameEncoderTest { @Test public void isValid() { - IncrementalBackupFileNameEncoder encoder = new IncrementalBackupFileNameEncoder(); + IncrementalBackupFileNameEncoder encoder = IncrementalBackupFileNameEncoder.INSTANCE; assertTrue(encoder.isValidFileName("incremental-0001-01-01_01-01-01_name.kbi")); assertTrue(encoder.isValidFileName("incremental-0001-01-01_01-01-01_0001-01-01_01-01-01_name.kbi")); assertFalse(encoder.isValidFileName("incremental-0001-01-01_01-01-01incremental-0001-01-01_01-01-01_name.kbi")); diff --git a/src/test/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethodTest.java b/src/test/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethodTest.java index 5fe0411..c69bd11 100644 --- a/src/test/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethodTest.java +++ b/src/test/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethodTest.java @@ -23,7 +23,7 @@ public class ConfiguredIncrementalBackupMethodTest { private final String sourceDirectoryName = "source"; private final String destDirectoryName = "destination"; private final String customBackupName = "index"; - private final String indexFileName = new IncrementalBackupFileNameEncoder().encode(customBackupName, LocalDateTime.now()); + private final String indexFileName = IncrementalBackupFileNameEncoder.INSTANCE.encode(customBackupName, LocalDateTime.now()); private final double directoryFactor = 0.05; private final double fileFactor = 0.1; -- cgit v1.2.3