📍Use lombok, reformat, and optimize the code (#1560)
* Use lombok, reformat, and optimize the code * Fix merge conflicts and some sonar issues Co-authored-by: va1m <va1m@email.com>
This commit is contained in:
@@ -23,15 +23,14 @@
|
||||
|
||||
package com.iluwatar.strangler;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* System under migration. Depends on old version source ({@link OldSource}) and
|
||||
* developing one ({@link HalfSource}).
|
||||
*/
|
||||
@Slf4j
|
||||
public class HalfArithmetic {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HalfArithmetic.class);
|
||||
private static final String VERSION = "1.5";
|
||||
|
||||
private final HalfSource newSource;
|
||||
@@ -65,7 +64,7 @@ public class HalfArithmetic {
|
||||
/**
|
||||
* Chech if has any zero.
|
||||
* @param nums numbers need to check
|
||||
* @return if has any zero, return true, else, return false
|
||||
* @return if has any zero, return true, else, return false
|
||||
*/
|
||||
public boolean ifHasZero(int... nums) {
|
||||
LOGGER.info("Arithmetic check zero {}", VERSION);
|
||||
|
@@ -24,15 +24,14 @@
|
||||
package com.iluwatar.strangler;
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Source under development. Replace part of old source and has added some new features.
|
||||
*/
|
||||
@Slf4j
|
||||
public class HalfSource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HalfSource.class);
|
||||
private static final String VERSION = "1.5";
|
||||
private static final String VERSION = "1.5";
|
||||
|
||||
/**
|
||||
* Implement accumulate sum with new technique.
|
||||
|
@@ -23,15 +23,14 @@
|
||||
|
||||
package com.iluwatar.strangler;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* System after whole migration. Only depends on new version source ({@link NewSource}).
|
||||
*/
|
||||
@Slf4j
|
||||
public class NewArithmetic {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(NewArithmetic.class);
|
||||
private static final String VERSION = "2.0";
|
||||
private static final String VERSION = "2.0";
|
||||
|
||||
private final NewSource source;
|
||||
|
||||
@@ -62,7 +61,7 @@ public class NewArithmetic {
|
||||
/**
|
||||
* Chech if has any zero.
|
||||
* @param nums numbers need to check
|
||||
* @return if has any zero, return true, else, return false
|
||||
* @return if has any zero, return true, else, return false
|
||||
*/
|
||||
public boolean ifHasZero(int... nums) {
|
||||
LOGGER.info("Arithmetic check zero {}", VERSION);
|
||||
|
@@ -24,16 +24,15 @@
|
||||
package com.iluwatar.strangler;
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* New source. Completely covers functionalities of old source with new techniques
|
||||
* and also has some new features.
|
||||
*/
|
||||
@Slf4j
|
||||
public class NewSource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(NewSource.class);
|
||||
private static final String VERSION = "2.0";
|
||||
private static final String VERSION = "2.0";
|
||||
public static final String SOURCE_MODULE = "Source module {}";
|
||||
|
||||
public int accumulateSum(int... nums) {
|
||||
|
@@ -23,15 +23,14 @@
|
||||
|
||||
package com.iluwatar.strangler;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Old version system depends on old version source ({@link OldSource}).
|
||||
*/
|
||||
@Slf4j
|
||||
public class OldArithmetic {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(OldArithmetic.class);
|
||||
private static final String VERSION = "1.0";
|
||||
private static final String VERSION = "1.0";
|
||||
|
||||
private final OldSource source;
|
||||
|
||||
|
@@ -23,14 +23,13 @@
|
||||
|
||||
package com.iluwatar.strangler;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Old source with techniques out of date.
|
||||
*/
|
||||
@Slf4j
|
||||
public class OldSource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(OldSource.class);
|
||||
private static final String VERSION = "1.0";
|
||||
|
||||
/**
|
||||
|
@@ -23,9 +23,10 @@
|
||||
|
||||
package com.iluwatar.strangler;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test methods in HalfArithmetic
|
||||
@@ -34,17 +35,17 @@ class HalfArithmeticTest {
|
||||
private static final HalfArithmetic arithmetic = new HalfArithmetic(new HalfSource(), new OldSource());
|
||||
|
||||
@Test
|
||||
public void testSum() {
|
||||
void testSum() {
|
||||
assertEquals(0, arithmetic.sum(-1, 0, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMul() {
|
||||
void testMul() {
|
||||
assertEquals(0, arithmetic.mul(-1, 0, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIfHasZero() {
|
||||
void testIfHasZero() {
|
||||
assertTrue(arithmetic.ifHasZero(-1, 0, 1));
|
||||
}
|
||||
}
|
@@ -23,11 +23,10 @@
|
||||
|
||||
package com.iluwatar.strangler;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test methods in HalfSource
|
||||
@@ -36,12 +35,12 @@ public class HalfSourceTest {
|
||||
private static final HalfSource source = new HalfSource();
|
||||
|
||||
@Test
|
||||
public void testAccumulateSum() {
|
||||
void testAccumulateSum() {
|
||||
assertEquals(0, source.accumulateSum(-1, 0, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIfNonZero() {
|
||||
void testIfNonZero() {
|
||||
assertFalse(source.ifNonZero(-1, 0, 1));
|
||||
}
|
||||
}
|
||||
|
@@ -23,9 +23,10 @@
|
||||
|
||||
package com.iluwatar.strangler;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test methods in NewArithmetic
|
||||
@@ -34,17 +35,17 @@ class NewArithmeticTest {
|
||||
private static final NewArithmetic arithmetic = new NewArithmetic(new NewSource());
|
||||
|
||||
@Test
|
||||
public void testSum() {
|
||||
void testSum() {
|
||||
assertEquals(0, arithmetic.sum(-1, 0, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMul() {
|
||||
void testMul() {
|
||||
assertEquals(0, arithmetic.mul(-1, 0, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIfHasZero() {
|
||||
void testIfHasZero() {
|
||||
assertTrue(arithmetic.ifHasZero(-1, 0, 1));
|
||||
}
|
||||
}
|
@@ -23,11 +23,11 @@
|
||||
|
||||
package com.iluwatar.strangler;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test methods in NewSource
|
||||
*/
|
||||
@@ -35,17 +35,17 @@ public class NewSourceTest {
|
||||
private static final NewSource source = new NewSource();
|
||||
|
||||
@Test
|
||||
public void testAccumulateSum() {
|
||||
void testAccumulateSum() {
|
||||
assertEquals(0, source.accumulateSum(-1, 0, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAccumulateMul() {
|
||||
void testAccumulateMul() {
|
||||
assertEquals(0, source.accumulateMul(-1, 0, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIfNonZero() {
|
||||
void testIfNonZero() {
|
||||
assertFalse(source.ifNonZero(-1, 0, 1));
|
||||
}
|
||||
}
|
||||
|
@@ -23,9 +23,9 @@
|
||||
|
||||
package com.iluwatar.strangler;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test methods in OldArithmetic
|
||||
@@ -34,12 +34,12 @@ class OldArithmeticTest {
|
||||
private static final OldArithmetic arithmetic = new OldArithmetic(new OldSource());
|
||||
|
||||
@Test
|
||||
public void testSum() {
|
||||
void testSum() {
|
||||
assertEquals(0, arithmetic.sum(-1, 0, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMul() {
|
||||
void testMul() {
|
||||
assertEquals(0, arithmetic.mul(-1, 0, 1));
|
||||
}
|
||||
}
|
@@ -23,10 +23,10 @@
|
||||
|
||||
package com.iluwatar.strangler;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test methods in OldSource
|
||||
*/
|
||||
@@ -34,12 +34,12 @@ public class OldSourceTest {
|
||||
private static final OldSource source = new OldSource();
|
||||
|
||||
@Test
|
||||
public void testAccumulateSum() {
|
||||
void testAccumulateSum() {
|
||||
assertEquals(0, source.accumulateSum(-1, 0, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAccumulateMul() {
|
||||
void testAccumulateMul() {
|
||||
assertEquals(0, source.accumulateMul(-1, 0, 1));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user