📍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:
va1m
2021-03-13 13:19:21 +01:00
committed by GitHub
parent 0e26a6adb5
commit 5cf2fe009b
681 changed files with 2472 additions and 4966 deletions

View File

@ -23,8 +23,7 @@
package com.iluwatar.combinator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
@ -41,13 +40,9 @@ import org.slf4j.LoggerFactory;
* {@link Finder#and(Finder)}
* Using them the became possible to get more complex functions {@link Finders}
*/
@Slf4j
public class CombinatorApp {
/**
* Logger.
*/
private static final Logger LOGGER = LoggerFactory.getLogger(CombinatorApp.class);
/**
* main.
* @param args args
@ -63,14 +58,13 @@ public class CombinatorApp {
res = finder.find(text());
LOGGER.info("the result of specialized(and) query[{}] is {}", queriesAnd, res);
finder = Finders.advancedFinder("it was","kingdom","sea");
finder = Finders.advancedFinder("it was", "kingdom", "sea");
res = finder.find(text());
LOGGER.info("the result of advanced query is {}", res);
res = Finders.filteredFinder(" was ", "many", "child").find(text());
LOGGER.info("the result of filtered query is {}", res);
}
private static String text() {

View File

@ -31,11 +31,10 @@ class CombinatorAppTest {
/**
* Issue: Add at least one assertion to this test case.
*
* <p>
* Solution: Inserted assertion to check whether the execution of the main method in {@link CombinatorApp#main(String[])}
* throws an exception.
*/
@Test
void shouldExecuteApplicationWithoutException() {
assertDoesNotThrow(() -> CombinatorApp.main(new String[]{}));

View File

@ -35,7 +35,6 @@ class FinderTest {
var result = Finder.contains("second").find(example);
assertEquals(1, result.size());
assertEquals("the second one ", result.get(0));
assertEquals( "the second one ", result.get(0));
}
}

View File

@ -35,36 +35,36 @@ class FindersTest {
@Test
void advancedFinderTest() {
var res = advancedFinder("it was","kingdom","sea").find(text());
var res = advancedFinder("it was", "kingdom", "sea").find(text());
assertEquals(1, res.size());
assertEquals("It was many and many a year ago,", res.get(0));
assertEquals( "It was many and many a year ago,", res.get(0));
}
@Test
void filteredFinderTest() {
var res = filteredFinder(" was ", "many", "child").find(text());
assertEquals(1, res.size());
assertEquals("But we loved with a love that was more than love-", res.get(0));
assertEquals( "But we loved with a love that was more than love-", res.get(0));
}
@Test
void specializedFinderTest() {
var res = specializedFinder("love","heaven").find(text());
var res = specializedFinder("love", "heaven").find(text());
assertEquals(1, res.size());
assertEquals("With a love that the winged seraphs of heaven", res.get(0));
assertEquals( "With a love that the winged seraphs of heaven", res.get(0));
}
@Test
void expandedFinderTest() {
var res = expandedFinder("It was","kingdom").find(text());
var res = expandedFinder("It was", "kingdom").find(text());
assertEquals(3, res.size());
assertEquals("It was many and many a year ago,", res.get(0));
assertEquals("In a kingdom by the sea,", res.get(1));
assertEquals("In this kingdom by the sea;", res.get(2));
assertEquals( "It was many and many a year ago,", res.get(0));
assertEquals( "In a kingdom by the sea,", res.get(1));
assertEquals( "In this kingdom by the sea;", res.get(2));
}
private String text(){
private String text() {
return
"It was many and many a year ago,\n"
+ "In a kingdom by the sea,\n"