dependencies: #2449 bump maven-checkstyle-plugin from 3.1.0 to 3.2.0 + resolve chec… (#2464)

* #2449 bump maven-checkstyle-plugin from 3.1.0 to 3.2.0 + resolve checkstyle issues

* remove FileSelectorJFrame.java to resolve checkstyle issue

* remove FileSelectorJFrame.java to resolve checkstyle issue

* remove FileSelectorJFrame.java to resolve checkstyle issue

* add refactored file with correct filename to resolve checkstyle issue

* add the test data

* change filenames from JFrame to Jframe for checkstyle

* fix code smell from  sonar report

* add new testcases to improve the test coverage

* remove code smell
This commit is contained in:
Rahul Raj
2023-02-04 22:50:54 +05:30
committed by GitHub
parent dbecffacab
commit fb7ec9b375
147 changed files with 487 additions and 289 deletions
@@ -25,7 +25,6 @@
package com.iluwatar.abstractdocument;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -28,7 +28,6 @@ import com.iluwatar.abstractdocument.domain.Car;
import com.iluwatar.abstractdocument.domain.Part;
import com.iluwatar.abstractdocument.domain.enums.Property;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Map;
@@ -27,6 +27,9 @@ package com.iluwatar.abstractfactory;
import lombok.Getter;
import lombok.Setter;
/**
* Helper class to manufacture {@link KingdomFactory} beans.
*/
@Getter
@Setter
public class Kingdom {
@@ -26,7 +26,6 @@ package com.iluwatar.activeobject;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -77,8 +76,8 @@ public abstract class ActiveCreature {
*/
public void eat() throws InterruptedException {
requests.put(() -> {
logger.info("{} is eating!",name());
logger.info("{} has finished eating!",name());
logger.info("{} is eating!", name());
logger.info("{} has finished eating!", name());
});
}
@@ -88,7 +87,7 @@ public abstract class ActiveCreature {
*/
public void roam() throws InterruptedException {
requests.put(() ->
logger.info("{} has started to roam in the wastelands.",name())
logger.info("{} has started to roam in the wastelands.", name())
);
}
@@ -26,7 +26,6 @@ package com.iluwatar.activeobject;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,7 +57,7 @@ public class App implements Runnable {
public void run() {
List<ActiveCreature> creatures = new ArrayList<>();
try {
for (int i = 0;i < NUM_CREATURES;i++) {
for (int i = 0; i < NUM_CREATURES; i++) {
creatures.add(new Orc(Orc.class.getSimpleName() + i));
creatures.get(i).eat();
creatures.get(i).roam();
@@ -68,7 +67,7 @@ public class App implements Runnable {
logger.error(e.getMessage());
Thread.currentThread().interrupt();
} finally {
for (int i = 0;i < NUM_CREATURES;i++) {
for (int i = 0; i < NUM_CREATURES; i++) {
creatures.get(i).kill(0);
}
}
@@ -26,7 +26,6 @@ package com.iluwatar.adapter;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
@@ -25,7 +25,6 @@
package com.iluwatar.business.delegate;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
@@ -25,9 +25,7 @@
package com.iluwatar.caching;
import com.iluwatar.caching.database.DbManager;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
/**
@@ -28,7 +28,6 @@ import com.iluwatar.caching.database.DbManager;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
/**
@@ -52,7 +52,7 @@ public class MongoDb implements DbManager {
private MongoClient client;
private MongoDatabase db;
void setDB(MongoDatabase db) {
void setDb(MongoDatabase db) {
this.db = db;
}
@@ -25,7 +25,6 @@
package com.iluwatar.caching.database;
import com.iluwatar.caching.UserAccount;
import java.util.HashMap;
import java.util.Map;
@@ -55,7 +55,7 @@ class MongoDbTest {
@BeforeEach
void init() {
db = mock(MongoDatabase.class);
mongoDb.setDB(db);
mongoDb.setDb(db);
userAccount = new UserAccount(ID, NAME, ADDITIONAL_INFO);
}
+1
View File
@@ -7,4 +7,5 @@
<suppress checks="[a-zA-Z0-9]*" files="[\\/]src[\\/]main[\\/]resources[\\/]" />
<suppress checks="LineLength" files="." />
<suppress checks="EmptyLineSeparator" files="." />
<suppress checks="RequireEmptyLineBeforeBlockTagGroup" files=".*\.java"/>
</suppressions>
@@ -27,7 +27,6 @@ package com.iluwatar.collectingparameter;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import java.util.LinkedList;
import java.util.Queue;
@@ -27,7 +27,6 @@ package com.iluwatar.collectingparameter;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import java.util.LinkedList;
import java.util.Queue;
@@ -25,7 +25,6 @@
package com.iluwatar.commander;
import com.iluwatar.commander.exceptions.DatabaseUnavailableException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Hashtable;
@@ -27,7 +27,6 @@ package com.iluwatar.commander.employeehandle;
import com.iluwatar.commander.Database;
import com.iluwatar.commander.Order;
import com.iluwatar.commander.exceptions.DatabaseUnavailableException;
import java.util.HashMap;
import java.util.Map;
@@ -37,10 +37,8 @@ import com.iluwatar.commander.paymentservice.PaymentService;
import com.iluwatar.commander.queue.QueueDatabase;
import com.iluwatar.commander.shippingservice.ShippingDatabase;
import com.iluwatar.commander.shippingservice.ShippingService;
import org.junit.jupiter.api.Test;
import org.junit.platform.commons.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
@@ -29,7 +29,6 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -26,6 +26,9 @@ package com.iluwatar.context.object;
import lombok.Getter;
/**
* Layer A in the context object pattern.
*/
@Getter
public class LayerA {
@@ -26,6 +26,9 @@ package com.iluwatar.context.object;
import lombok.Getter;
/**
* Layer B in the context object pattern.
*/
@Getter
public class LayerB {
@@ -26,6 +26,9 @@ package com.iluwatar.context.object;
import lombok.Getter;
/**
* Layer C in the context object pattern.
*/
@Getter
public class LayerC {
@@ -27,7 +27,7 @@ package com.iluwatar.cqrs.commandes;
/**
* This interface represents the commands of the CQRS pattern.
*/
public interface ICommandService {
public interface CommandService {
void authorCreated(String username, String name, String email);
@@ -30,10 +30,10 @@ import com.iluwatar.cqrs.util.HibernateUtil;
import org.hibernate.SessionFactory;
/**
* This class is an implementation of {@link ICommandService} interface. It uses Hibernate as an api
* This class is an implementation of {@link CommandService} interface. It uses Hibernate as an api
* for persistence.
*/
public class CommandServiceImpl implements ICommandService {
public class CommandServiceImpl implements CommandService {
private final SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
@@ -32,7 +32,7 @@ import java.util.List;
/**
* This interface represents the query methods of the CQRS pattern.
*/
public interface IQueryService {
public interface QueryService {
Author getAuthorByUsername(String username);
@@ -34,51 +34,51 @@ import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
/**
* This class is an implementation of {@link IQueryService}. It uses Hibernate native queries to
* This class is an implementation of {@link QueryService}. It uses Hibernate native queries to
* return DTOs from the database.
*/
public class QueryServiceImpl implements IQueryService {
public class QueryServiceImpl implements QueryService {
private final SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
@Override
public Author getAuthorByUsername(String username) {
Author authorDTo;
Author authorDto;
try (var session = sessionFactory.openSession()) {
Query<Author> sqlQuery = session.createQuery(
"select new com.iluwatar.cqrs.dto.Author(a.name, a.email, a.username)"
+ " from com.iluwatar.cqrs.domain.model.Author a where a.username=:username");
sqlQuery.setParameter(AppConstants.USER_NAME, username);
authorDTo = sqlQuery.uniqueResult();
authorDto = sqlQuery.uniqueResult();
}
return authorDTo;
return authorDto;
}
@Override
public Book getBook(String title) {
Book bookDTo;
Book bookDto;
try (var session = sessionFactory.openSession()) {
Query<Book> sqlQuery = session.createQuery(
"select new com.iluwatar.cqrs.dto.Book(b.title, b.price)"
+ " from com.iluwatar.cqrs.domain.model.Book b where b.title=:title");
sqlQuery.setParameter("title", title);
bookDTo = sqlQuery.uniqueResult();
bookDto = sqlQuery.uniqueResult();
}
return bookDTo;
return bookDto;
}
@Override
public List<Book> getAuthorBooks(String username) {
List<Book> bookDTos;
List<Book> bookDtos;
try (var session = sessionFactory.openSession()) {
Query<Book> sqlQuery = session.createQuery(
"select new com.iluwatar.cqrs.dto.Book(b.title, b.price)"
+ " from com.iluwatar.cqrs.domain.model.Author a, com.iluwatar.cqrs.domain.model.Book b "
+ "where b.author.id = a.id and a.username=:username");
sqlQuery.setParameter(AppConstants.USER_NAME, username);
bookDTos = sqlQuery.list();
bookDtos = sqlQuery.list();
}
return bookDTos;
return bookDtos;
}
@Override
@@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import com.iluwatar.cqrs.commandes.CommandServiceImpl;
import com.iluwatar.cqrs.dto.Author;
import com.iluwatar.cqrs.dto.Book;
import com.iluwatar.cqrs.queries.IQueryService;
import com.iluwatar.cqrs.queries.QueryService;
import com.iluwatar.cqrs.queries.QueryServiceImpl;
import java.math.BigInteger;
import org.junit.jupiter.api.BeforeAll;
@@ -41,7 +41,7 @@ import org.junit.jupiter.api.Test;
*/
class IntegrationTest {
private static IQueryService queryService;
private static QueryService queryService;
@BeforeAll
static void initializeAndPopulateDatabase() {
@@ -28,7 +28,6 @@ import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.time.LocalDate;
/**
@@ -29,7 +29,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.List;
import com.iluwatar.datatransfer.customer.CustomerDto;
import com.iluwatar.datatransfer.customer.CustomerResource;
import org.junit.jupiter.api.Test;
@@ -28,7 +28,6 @@ import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
@@ -29,7 +29,6 @@ import static org.joda.money.CurrencyUnit.USD;
import java.sql.SQLException;
import java.time.LocalDate;
import javax.sql.DataSource;
import org.h2.jdbcx.JdbcDataSource;
import org.joda.money.Money;
@@ -28,7 +28,6 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import lombok.Builder;
import lombok.Getter;
import lombok.NonNull;
@@ -27,6 +27,9 @@ package com.iluwatar.domainmodel;
import java.sql.SQLException;
import java.util.Optional;
/**
* DAO interface for customer transactions.
*/
public interface CustomerDao {
Optional<Customer> findByName(String name) throws SQLException;
@@ -30,9 +30,11 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Optional;
import javax.sql.DataSource;
import org.joda.money.Money;
/**
* Implementations for database operations of Customer.
*/
public class CustomerDaoImpl implements CustomerDao {
private final DataSource dataSource;
@@ -31,7 +31,6 @@ import java.sql.SQLException;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.Optional;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
@@ -27,6 +27,9 @@ package com.iluwatar.domainmodel;
import java.sql.SQLException;
import java.util.Optional;
/**
* DAO interface for product transactions.
*/
public interface ProductDao {
Optional<Product> findByName(String name) throws SQLException;
@@ -31,10 +31,11 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Optional;
import javax.sql.DataSource;
import org.joda.money.Money;
/**
* Implementations for database transactions of Product.
*/
public class ProductDaoImpl implements ProductDao {
private final DataSource dataSource;
@@ -29,7 +29,6 @@ import org.joda.money.Money;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import javax.sql.DataSource;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -28,7 +28,6 @@ import org.joda.money.CurrencyUnit;
import org.joda.money.Money;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.sql.SQLException;
import java.time.LocalDate;
import java.util.ArrayList;
@@ -28,7 +28,6 @@ import org.joda.money.Money;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import javax.sql.DataSource;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -27,7 +27,6 @@ package com.iluwatar.domainmodel;
import org.joda.money.Money;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.sql.SQLException;
import java.time.LocalDate;
import java.util.Optional;
@@ -25,7 +25,6 @@
package com.iluwatar.domainmodel;
import org.h2.jdbcx.JdbcDataSource;
import javax.sql.DataSource;
import java.sql.SQLException;
@@ -25,22 +25,20 @@
package com.iluwatar.embedded.value;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
/*
* Many small objects make sense in an OO system that dont make sense as
/**
* <p> Many small objects make sense in an OO system that dont make sense as
* tables in a database. Examples include currency-aware money objects (amount, currency) and date
* ranges. Although the default thinking is to save an object as a table, no sane
* person would want a table of money values.
* person would want a table of money values. </p>
*
* An Embedded Value maps the values of an object to fields in the record of
* <p> An Embedded Value maps the values of an object to fields in the record of
* the objects owner. In this implementation we have an Order object with links to an
* ShippingAddress object. In the resulting table the fields in the ShippingAddress
* object map to fields in the Order table rather than make new records
* themselves.
* themselves. </p>
*/
@Slf4j
public class App {
@@ -62,11 +60,9 @@ public class App {
final var order3 = new Order("Carrie Soto is Back", "Shiva",
new ShippingAddress("Bangalore", "Karnataka", "560004"));
/**
* Create table for orders - Orders(id, name, orderedBy, city, state, pincode).
* We can see that table is different from the Order object we have.
* We're mapping ShippingAddress into city, state, pincode colummns of the database and not creating a separate table.
*/
// Create table for orders - Orders(id, name, orderedBy, city, state, pincode).
// We can see that table is different from the Order object we have.
// We're mapping ShippingAddress into city, state, pincode colummns of the database and not creating a separate table.
if (dataSource.createSchema()) {
LOGGER.info("TABLE CREATED");
LOGGER.info("Table \"Orders\" schema:\n" + dataSource.getSchema());
@@ -84,21 +80,17 @@ public class App {
dataSource.insertOrder(order2);
dataSource.insertOrder(order3);
/**
* Query orders
* We'll create ShippingAddress object from city, state, pincode values from the table
* and add it to Order object
*/
// Query orders.
// We'll create ShippingAddress object from city, state, pincode values from the table and add it to Order object
LOGGER.info("Orders Query: {}", dataSource.queryOrders().collect(Collectors.toList()) + "\n");
//Query order by given id
LOGGER.info("Query Order with id=2: {}", dataSource.queryOrder(2));
/**
* Remove order by given id.
* Since we'd mapped address in the same table, deleting order will also take
* out the shipping address details
*/
//Remove order by given id.
//Since we'd mapped address in the same table, deleting order will also take out the shipping address details.
LOGGER.info("Remove Order with id=1");
dataSource.removeOrder(1);
LOGGER.info("\nOrders Query: {}", dataSource.queryOrders().collect(Collectors.toList()) + "\n");
@@ -31,36 +31,29 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
/*
* Communicates with H2 database with the help of JDBC API
*
* Inherits the SQL queries and methods from @link AbstractDataSource class
*/
/**
* Communicates with H2 database with the help of JDBC API.
* Inherits the SQL queries and methods from @link AbstractDataSource class.
*/
@Slf4j
public class DataSource implements DataSourceInterface {
private Connection conn;
/**
* Statements are objects which are used to execute queries which will not be
* repeated.
*/
// Statements are objects which are used to execute queries which will not be repeated.
private Statement getschema;
private Statement deleteschema;
private Statement queryOrders;
/*
* PreparedStatements are used to execute queries which will be repeated.
*/
// PreparedStatements are used to execute queries which will be repeated.
private PreparedStatement insertIntoOrders;
private PreparedStatement removeorder;
private PreparedStatement queyOrderByID;
private PreparedStatement queyOrderById;
/**
* {@summary}
* Establish connection to database.
* {@summary Establish connection to database.
* Constructor to create DataSource object.}
*/
public DataSource() {
try {
@@ -79,7 +72,7 @@ public class DataSource implements DataSourceInterface {
getschema = conn.createStatement();
queryOrders = conn.createStatement();
removeorder = conn.prepareStatement(REMOVE_ORDER);
queyOrderByID = conn.prepareStatement(QUERY_ORDER);
queyOrderById = conn.prepareStatement(QUERY_ORDER);
deleteschema = conn.createStatement();
} catch (SQLException e) {
LOGGER.error(e.getLocalizedMessage(), e.getCause());
@@ -156,7 +149,6 @@ public class DataSource implements DataSourceInterface {
}
/**
* {@summary}
* Query order by given id.
* @param id as the parameter
* @return Order objct
@@ -166,9 +158,9 @@ public class DataSource implements DataSourceInterface {
@Override
public Order queryOrder(int id) throws SQLException {
Order order = null;
queyOrderByID.setInt(1, id);
try (var rSet = queyOrderByID.executeQuery()) {
queyOrderByID.setInt(1, id);
queyOrderById.setInt(1, id);
try (var rSet = queyOrderById.executeQuery()) {
queyOrderById.setInt(1, id);
if (rSet.next()) {
var address = new ShippingAddress(rSet.getString(4),
rSet.getString(5), rSet.getString(6));
@@ -204,7 +196,7 @@ public class DataSource implements DataSourceInterface {
try {
deleteschema.execute(DELETE_SCHEMA);
queryOrders.close();
queyOrderByID.close();
queyOrderById.close();
deleteschema.close();
insertIntoOrders.close();
conn.close();
@@ -27,7 +27,8 @@ package com.iluwatar.embedded.value;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/*
/**
* A POJO which represents the Order object.
*/
@ToString
@@ -63,8 +63,8 @@ public abstract class EventEmitter {
protected void notifyObservers(Event e) {
if (observerLists.containsKey(e)) {
observerLists
.get(e)
.forEach(observer -> observer.onEvent(e));
.get(e)
.forEach(observer -> observer.onEvent(e));
}
}
@@ -53,7 +53,7 @@ import lombok.extern.slf4j.Slf4j;
* Communicate with pending asynchronous operations using the familiar events-and-delegates model.
*
* @see EventManager
* @see Event
* @see AsyncEvent
*/
@Slf4j
public class App {
@@ -0,0 +1,99 @@
/*
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
*
* The MIT License
* Copyright © 2014-2022 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.event.asynchronous;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
* Each Event runs as a separate/individual thread.
*/
@Slf4j
@RequiredArgsConstructor
public class AsyncEvent implements Event, Runnable {
private final int eventId;
private final int eventTime;
@Getter
private final boolean synchronous;
private Thread thread;
private boolean isComplete = false;
private ThreadCompleteListener eventListener;
@Override
public void start() {
thread = new Thread(this);
thread.start();
}
@Override
public void stop() {
if (null == thread) {
return;
}
thread.interrupt();
}
@Override
public void status() {
if (!isComplete) {
LOGGER.info("[{}] is not done.", eventId);
} else {
LOGGER.info("[{}] is done.", eventId);
}
}
@Override
public void run() {
var currentTime = System.currentTimeMillis();
var endTime = currentTime + (eventTime * 1000);
while (System.currentTimeMillis() < endTime) {
try {
Thread.sleep(1000); // Sleep for 1 second.
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
}
isComplete = true;
completed();
}
public final void addListener(final ThreadCompleteListener listener) {
this.eventListener = listener;
}
public final void removeListener() {
this.eventListener = null;
}
private void completed() {
if (eventListener != null) {
eventListener.completedEventHandler(eventId);
}
}
}
@@ -24,76 +24,15 @@
*/
package com.iluwatar.event.asynchronous;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
* Each Event runs as a separate/individual thread.
* Events that fulfill the start stop and list out current status behaviour follow this interface.
*/
@Slf4j
@RequiredArgsConstructor
public class Event implements IEvent, Runnable {
public interface Event {
private final int eventId;
private final int eventTime;
@Getter
private final boolean synchronous;
private Thread thread;
private boolean isComplete = false;
private ThreadCompleteListener eventListener;
void start();
@Override
public void start() {
thread = new Thread(this);
thread.start();
}
void stop();
@Override
public void stop() {
if (null == thread) {
return;
}
thread.interrupt();
}
@Override
public void status() {
if (!isComplete) {
LOGGER.info("[{}] is not done.", eventId);
} else {
LOGGER.info("[{}] is done.", eventId);
}
}
@Override
public void run() {
var currentTime = System.currentTimeMillis();
var endTime = currentTime + (eventTime * 1000);
while (System.currentTimeMillis() < endTime) {
try {
Thread.sleep(1000); // Sleep for 1 second.
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
}
isComplete = true;
completed();
}
public final void addListener(final ThreadCompleteListener listener) {
this.eventListener = listener;
}
public final void removeListener(final ThreadCompleteListener listener) {
this.eventListener = null;
}
private void completed() {
if (eventListener != null) {
eventListener.completedEventHandler(eventId);
}
}
void status();
}
@@ -29,7 +29,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* EventManager handles and maintains a pool of event threads. {@link Event} threads are created
* EventManager handles and maintains a pool of event threads. {@link AsyncEvent} threads are created
* upon user request. Thre are two types of events; Asynchronous and Synchronous. There can be
* multiple Asynchronous events running at once but only one Synchronous event running at a time.
* Currently supported event operations are: start, stop, and getStatus. Once an event is complete,
@@ -45,7 +45,7 @@ public class EventManager implements ThreadCompleteListener {
public static final int MAX_EVENT_TIME = 1800; // in seconds / 30 minutes.
private int currentlyRunningSyncEvent = -1;
private final SecureRandom rand;
private final Map<Integer, Event> eventPool;
private final Map<Integer, AsyncEvent> eventPool;
private static final String DOES_NOT_EXIST = " does not exist.";
@@ -108,7 +108,7 @@ public class EventManager implements ThreadCompleteListener {
var newEventId = generateId();
var newEvent = new Event(newEventId, eventTime, isSynchronous);
var newEvent = new AsyncEvent(newEventId, eventTime, isSynchronous);
newEvent.addListener(this);
eventPool.put(newEventId, newEvent);
@@ -167,7 +167,7 @@ public class EventManager implements ThreadCompleteListener {
*/
@SuppressWarnings("rawtypes")
public void statusOfAllEvents() {
eventPool.entrySet().forEach(entry -> ((Event) ((Map.Entry) entry).getValue()).status());
eventPool.entrySet().forEach(entry -> ((AsyncEvent) ((Map.Entry) entry).getValue()).status());
}
/**
@@ -175,7 +175,7 @@ public class EventManager implements ThreadCompleteListener {
*/
@SuppressWarnings("rawtypes")
public void shutdown() {
eventPool.entrySet().forEach(entry -> ((Event) ((Map.Entry) entry).getValue()).stop());
eventPool.entrySet().forEach(entry -> ((AsyncEvent) ((Map.Entry) entry).getValue()).stop());
}
/**
@@ -195,7 +195,7 @@ public class EventManager implements ThreadCompleteListener {
}
/**
* Callback from an {@link Event} (once it is complete). The Event is then removed from the pool.
* Callback from an {@link AsyncEvent} (once it is complete). The Event is then removed from the pool.
*/
@Override
public void completedEventHandler(int eventId) {
@@ -209,7 +209,7 @@ public class EventManager implements ThreadCompleteListener {
/**
* Getter method for event pool.
*/
public Map<Integer, Event> getEventPool() {
public Map<Integer, AsyncEvent> getEventPool() {
return eventPool;
}
@@ -136,4 +136,26 @@ class EventAsynchronousTest {
LOGGER.error(e.getMessage());
}
}
}
@Test
void testLongRunningEventException(){
assertThrows(LongRunningEventException.class, () -> {
var eventManager = new EventManager();
eventManager.createAsync(2000);
});
}
@Test
void testMaxNumOfEventsAllowedException(){
assertThrows(MaxNumOfEventsAllowedException.class, () -> {
final var eventManager = new EventManager();
for(int i=0;i<1100;i++){
eventManager.createAsync(i);
}
});
}
}
@@ -27,7 +27,6 @@ package com.iluwatar.execute.around;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
import lombok.extern.slf4j.Slf4j;
/**
@@ -26,7 +26,6 @@ package com.iluwatar.execute.around;
import java.io.FileWriter;
import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
/**
@@ -31,7 +31,6 @@ import ch.qos.logback.core.read.ListAppender;
import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import units.CommanderUnit;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -31,7 +31,6 @@ import ch.qos.logback.core.read.ListAppender;
import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
import units.SergeantUnit;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -25,7 +25,6 @@
package com.iluwatar.factorykit;
import java.util.ArrayList;
import lombok.extern.slf4j.Slf4j;
/**
@@ -26,7 +26,6 @@ package com.iluwatar.fanout.fanin;
import java.util.Arrays;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
@@ -25,7 +25,6 @@
package com.iluwatar.fanout.fanin;
import java.util.concurrent.atomic.AtomicLong;
import lombok.Getter;
@@ -25,7 +25,6 @@
package com.iluwatar.fanout.fanin;
import java.security.SecureRandom;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -26,7 +26,6 @@ package com.iluwatar.fanout.fanin;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.List;
@@ -25,7 +25,6 @@
package com.iluwatar.filterer.threat;
import com.iluwatar.filterer.domain.Filterer;
import java.util.List;
/**
@@ -35,14 +34,14 @@ public interface ProbabilisticThreatAwareSystem extends ThreatAwareSystem {
/**
* {@inheritDoc}
* @return
* @return {@link ProbableThreat}
*/
@Override
List<? extends ProbableThreat> threats();
/**
* {@inheritDoc}
* @return
* @return {@link Filterer}
*/
@Override
Filterer<? extends ProbabilisticThreatAwareSystem, ? extends ProbableThreat> filtered();
@@ -25,7 +25,6 @@
package com.iluwatar.filterer.threat;
import com.iluwatar.filterer.domain.Filterer;
import java.util.List;
/**
@@ -24,6 +24,9 @@
*/
package com.iluwatar.filterer.threat;
/**
* Enum class representing Threat types.
*/
public enum ThreatType {
TROJAN,
WORM,
@@ -25,7 +25,6 @@
package com.iluwatar.filterer.threat;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
@@ -28,7 +28,6 @@ import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
@@ -24,6 +24,9 @@
*/
package com.iluwatar.identitymap;
/**
* Using Runtime Exception to control the flow in case Person Id doesn not exist.
*/
public class IdNotFoundException extends RuntimeException {
public IdNotFoundException(final String message) {
super(message);
@@ -26,7 +26,6 @@ package com.iluwatar.identitymap;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
@@ -25,7 +25,6 @@
package com.iluwatar.identitymap;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -24,13 +24,16 @@
*/
package com.iluwatar.identitymap;
/**
* Simulator interface for Person DB.
*/
public interface PersonDbSimulator {
Person find(int personNationalID);
Person find(int personNationalId);
void insert(Person person);
void update(Person person);
void delete(int personNationalID);
void delete(int personNationalId);
}
@@ -27,7 +27,6 @@ package com.iluwatar.identitymap;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
/**
@@ -49,10 +48,10 @@ public class PersonDbSimulatorImplementation implements PersonDbSimulator {
static final String ID_STR = "ID : ";
@Override
public Person find(int personNationalID) throws IdNotFoundException {
Optional<Person> elem = personList.stream().filter(p -> p.getPersonNationalId() == personNationalID).findFirst();
public Person find(int personNationalId) throws IdNotFoundException {
Optional<Person> elem = personList.stream().filter(p -> p.getPersonNationalId() == personNationalId).findFirst();
if (elem.isEmpty()) {
throw new IdNotFoundException(ID_STR + personNationalID + NOT_IN_DATA_BASE);
throw new IdNotFoundException(ID_STR + personNationalId + NOT_IN_DATA_BASE);
}
LOGGER.info(elem.get().toString());
return elem.get();
@@ -76,7 +76,7 @@ public class Target extends JFrame { //NOSONAR
jsp.setPreferredSize(new Dimension(500, 250));
add(jsp, BorderLayout.CENTER);
del.addActionListener(new DListener());
del.addActionListener(new TargetListener());
var rootPane = SwingUtilities.getRootPane(del);
rootPane.setDefaultButton(del);
@@ -87,7 +87,7 @@ public class Target extends JFrame { //NOSONAR
dtm.addRow(new Object[]{request[0], request[1], request[2], request[3], request[4]});
}
class DListener implements ActionListener {
class TargetListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
var temp = jt.getSelectedRow();
@@ -0,0 +1,46 @@
/*
* This project is licensed under the MIT license. Module intercepting-filter is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
*
* The MIT License
* Copyright © 2014-2022 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.intercepting.filter;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Test;
/**
* Date: 01/29/23 - 1:33 PM
*
* @author Rahul Raj
*/
class TargetTest {
@Test
void testSetup(){
final var target = new Target();
assertEquals(target.getSize().getWidth(), Double.valueOf(640));
assertEquals(target.getSize().getHeight(), Double.valueOf(480));
assertEquals(true,target.isVisible());
}
}
@@ -26,7 +26,6 @@ package com.iluwatar.layers.entity;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
@@ -27,6 +27,9 @@ package com.iluwatar.leaderfollowers;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
/**
* Worker class that takes work from work center.
*/
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Slf4j
public class Worker implements Runnable {
@@ -62,7 +62,7 @@ public class App {
// get service
var userService = new UserService();
// use create service to add users
for (var user: generateSampleUsers()) {
for (var user : generateSampleUsers()) {
var id = userService.createUser(user);
LOGGER.info("Add user" + user + "at" + id + ".");
}
@@ -47,9 +47,6 @@ public class DatabaseUtil {
*/
private DatabaseUtil() {}
/**
* Create database.
*/
static {
LOGGER.info("create h2 database");
var source = new JdbcDataSource();
@@ -2,7 +2,6 @@ package com.iluwatar.model.view.intent;
import com.iluwatar.model.view.intent.actions.*;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.1.8" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
realizations="true" associations="true" dependencies="false" nesting-relationships="true">
<class id="1" language="java" name="com.iluwatar.model.view.presenter.FileSelectorJFrame"
<class id="1" language="java" name="com.iluwatar.model.view.presenter.FileSelectorJframe"
project="model-view-presenter"
file="/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorJFrame.java" binary="false"
file="/model-view-presenter/src/main/java/com/iluwatar/model/view/presenter/FileSelectorJframe.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="430" width="259" x="33" y="149"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -16,7 +16,7 @@ package com.iluwatar.model.view.presenter {
+ loadData() : String
+ setFileName(fileName : String)
}
class FileSelectorJFrame {
class FileSelectorJframe {
- area : JTextArea
- cancel : JButton
- contents : JLabel
@@ -27,7 +27,7 @@ package com.iluwatar.model.view.presenter {
- panel : JPanel
- presenter : FileSelectorPresenter
- serialVersionUID : long {static}
+ FileSelectorJFrame()
+ FileSelectorJframe()
+ actionPerformed(e : ActionEvent)
+ close()
+ displayData(data : String)
@@ -81,10 +81,10 @@ package com.iluwatar.model.view.presenter {
+ showMessage(String) {abstract}
}
}
FileSelectorJFrame --> "-presenter" FileSelectorPresenter
FileSelectorJframe --> "-presenter" FileSelectorPresenter
FileSelectorStub --> "-presenter" FileSelectorPresenter
FileSelectorPresenter --> "-view" FileSelectorView
FileSelectorPresenter --> "-loader" FileLoader
FileSelectorJFrame ..|> FileSelectorView
FileSelectorJframe ..|> FileSelectorView
FileSelectorStub ..|> FileSelectorView
@enduml
@@ -31,7 +31,7 @@ package com.iluwatar.model.view.presenter;
* (Presenter).
*
* <p>In the following example, The {@link FileLoader} class represents the app's logic, the {@link
* FileSelectorJFrame} is the GUI and the {@link FileSelectorPresenter} is responsible to respond to
* FileSelectorJframe} is the GUI and the {@link FileSelectorPresenter} is responsible to respond to
* users' actions.
*
* <p>Finally, please notice the wiring between the Presenter and the View and between the
@@ -46,7 +46,7 @@ public class App {
*/
public static void main(String[] args) {
var loader = new FileLoader();
var frame = new FileSelectorJFrame();
var frame = new FileSelectorJframe();
var presenter = new FileSelectorPresenter(frame);
presenter.setLoader(loader);
presenter.start();
@@ -30,7 +30,6 @@ import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
@@ -43,7 +42,7 @@ import javax.swing.JTextField;
/**
* This class is the GUI implementation of the View component in the Model-View-Presenter pattern.
*/
public class FileSelectorJFrame extends JFrame implements FileSelectorView, ActionListener {
public class FileSelectorJframe extends JFrame implements FileSelectorView, ActionListener {
/**
* Default serial version ID.
@@ -83,7 +82,7 @@ public class FileSelectorJFrame extends JFrame implements FileSelectorView, Acti
/**
* Constructor.
*/
public FileSelectorJFrame() {
public FileSelectorJframe() {
super("File Loader");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLayout(null);
@@ -1,5 +1,5 @@
/*
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
* This project is licensed under the MIT license. Module model-view-presenter is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
*
* The MIT License
* Copyright © 2014-2022 Ilkka Seppälä
@@ -22,17 +22,31 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.event.asynchronous;
package com.iluwatar.model.view.presenter;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import java.awt.event.ActionEvent;
import org.junit.jupiter.api.Test;
/**
* Events that fulfill the start stop and list out current status behaviour follow this interface.
* Date: 01/29/23 - 6:00 PM
*
* @author Rahul Raj
*/
public interface IEvent {
void start();
void stop();
void status();
class FileSelectorJframeTest {
/**
* Tests if the jframe action event is triggered without any exception.
*/
@Test
void testActionEvent() {
assertDoesNotThrow(() ->{
FileSelectorJframe jFrame = new FileSelectorJframe();
ActionEvent action = new ActionEvent("dummy", 1, "dummy");
jFrame.actionPerformed(action);
});
}
}
@@ -144,4 +144,16 @@ class FileSelectorPresenterTest {
assertFalse(stub.isOpened());
}
@Test
void testNullFile() {
stub.setFileName(null);
presenter.start();
presenter.fileNameChanged();
presenter.confirmed();
assertFalse(loader.isLoaded());
assertFalse(stub.dataDisplayed());
}
}
@@ -27,6 +27,9 @@ package com.iluwatar.model.view.viewmodel;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* Book class.
*/
@AllArgsConstructor
@Data
public class Book {
@@ -27,6 +27,9 @@ package com.iluwatar.model.view.viewmodel;
import java.util.List;
/**
* Class representing a service to load books.
*/
public interface BookService {
/* List all books
* @return all books
@@ -27,6 +27,9 @@ package com.iluwatar.model.view.viewmodel;
import java.util.ArrayList;
import java.util.List;
/**
* Class that actually implement the books to load.
*/
public class BookServiceImpl implements BookService {
private List<Book> designPatternBooks = new ArrayList<>();
@@ -25,11 +25,13 @@
package com.iluwatar.model.view.viewmodel;
import java.util.List;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.select.annotation.WireVariable;
/**
* BookViewModel class.
*/
public class BookViewModel {
@WireVariable
@@ -56,7 +58,7 @@ public class BookViewModel {
* and used to delete the selected book from the list of books.
*/
@Command
@NotifyChange({"selectedBook","bookList"})
@NotifyChange({"selectedBook", "bookList"})
public void deleteBook() {
if (selectedBook != null) {
getBookList().remove(selectedBook);
@@ -24,9 +24,9 @@
*/
package com.iluwatar.observer;
import com.iluwatar.observer.generic.GHobbits;
import com.iluwatar.observer.generic.GOrcs;
import com.iluwatar.observer.generic.GWeather;
import com.iluwatar.observer.generic.GenHobbits;
import com.iluwatar.observer.generic.GenOrcs;
import com.iluwatar.observer.generic.GenWeather;
import lombok.extern.slf4j.Slf4j;
/**
@@ -61,9 +61,9 @@ public class App {
// Generic observer inspired by Java Generics and Collections by Naftalin & Wadler
LOGGER.info("--Running generic version--");
var genericWeather = new GWeather();
genericWeather.addObserver(new GOrcs());
genericWeather.addObserver(new GHobbits());
var genericWeather = new GenWeather();
genericWeather.addObserver(new GenOrcs());
genericWeather.addObserver(new GenHobbits());
genericWeather.timePasses();
genericWeather.timePasses();
@@ -31,10 +31,10 @@ import lombok.extern.slf4j.Slf4j;
* GHobbits.
*/
@Slf4j
public class GHobbits implements Race {
public class GenHobbits implements Race {
@Override
public void update(GWeather weather, WeatherType weatherType) {
public void update(GenWeather weather, WeatherType weatherType) {
LOGGER.info("The hobbits are facing " + weatherType.getDescription() + " weather now");
}
}
@@ -31,10 +31,10 @@ import lombok.extern.slf4j.Slf4j;
* GOrcs.
*/
@Slf4j
public class GOrcs implements Race {
public class GenOrcs implements Race {
@Override
public void update(GWeather weather, WeatherType weatherType) {
public void update(GenWeather weather, WeatherType weatherType) {
LOGGER.info("The orcs are facing " + weatherType.getDescription() + " weather now");
}
}
@@ -31,11 +31,11 @@ import lombok.extern.slf4j.Slf4j;
* GWeather.
*/
@Slf4j
public class GWeather extends Observable<GWeather, Race, WeatherType> {
public class GenWeather extends Observable<GenWeather, Race, WeatherType> {
private WeatherType currentWeather;
public GWeather() {
public GenWeather() {
currentWeather = WeatherType.SUNNY;
}
@@ -29,5 +29,5 @@ import com.iluwatar.observer.WeatherType;
/**
* Race.
*/
public interface Race extends Observer<GWeather, Race, WeatherType> {
public interface Race extends Observer<GenWeather, Race, WeatherType> {
}
@@ -28,7 +28,6 @@ import com.iluwatar.observer.utils.InMemoryAppender;
import java.util.Collection;
import java.util.function.Supplier;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
@@ -25,7 +25,6 @@
package com.iluwatar.observer.generic;
import com.iluwatar.observer.WeatherType;
import java.util.Collection;
import java.util.List;
@@ -34,7 +33,7 @@ import java.util.List;
*
* @author Jeroen Meulemeester
*/
class GHobbitsTest extends ObserverTest<GHobbits> {
class GHobbitsTest extends ObserverTest<GenHobbits> {
@Override
public Collection<Object[]> dataProvider() {
@@ -50,7 +49,7 @@ class GHobbitsTest extends ObserverTest<GHobbits> {
* Create a new test with the given weather and expected response
*/
public GHobbitsTest() {
super(GHobbits::new);
super(GenHobbits::new);
}
}
@@ -48,7 +48,7 @@ class GWeatherTest {
@BeforeEach
void setUp() {
appender = new InMemoryAppender(GWeather.class);
appender = new InMemoryAppender(GenWeather.class);
}
@AfterEach
@@ -64,7 +64,7 @@ class GWeatherTest {
void testAddRemoveObserver() {
final var observer = mock(Race.class);
final var weather = new GWeather();
final var weather = new GenWeather();
weather.addObserver(observer);
verifyNoMoreInteractions(observer);
@@ -86,7 +86,7 @@ class GWeatherTest {
@Test
void testTimePasses() {
final var observer = mock(Race.class);
final var weather = new GWeather();
final var weather = new GenWeather();
weather.addObserver(observer);
final var inOrder = inOrder(observer);
@@ -25,7 +25,6 @@
package com.iluwatar.observer.generic;
import com.iluwatar.observer.WeatherType;
import java.util.Collection;
import java.util.List;
@@ -34,7 +33,7 @@ import java.util.List;
*
* @author Jeroen Meulemeester
*/
class OrcsTest extends ObserverTest<GOrcs> {
class OrcsTest extends ObserverTest<GenOrcs> {
@Override
public Collection<Object[]> dataProvider() {
@@ -50,7 +49,7 @@ class OrcsTest extends ObserverTest<GOrcs> {
* Create a new test with the given weather and expected response
*/
public OrcsTest() {
super(GOrcs::new);
super(GenOrcs::new);
}
}
@@ -28,7 +28,6 @@ import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
@@ -24,6 +24,9 @@
*/
package com.iluwatar.parameter.object;
/**
* ParameterObject.
*/
public class ParameterObject {
/**
@@ -83,6 +86,9 @@ public class ParameterObject {
type, sortBy, sortOrder);
}
/**
* Builder for ParameterObject.
*/
public static final class Builder {
private String type;
@@ -24,6 +24,9 @@
*/
package com.iluwatar.parameter.object;
/**
* SearchService to demonstrate parameter object pattern.
*/
public class SearchService {
/**
@@ -24,6 +24,9 @@
*/
package com.iluwatar.parameter.object;
/**
* enum for sort order types.
*/
public enum SortOrder {
ASC("asc"),
DESC("desc");

Some files were not shown because too many files have changed in this diff Show More