Merge pull request #548 from muditporwal/master
Checkstyle improvements #539 : Added JavaDocType Rule
This commit is contained in:
commit
3f272bf291
@ -28,6 +28,9 @@ import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test for abstract factory
|
||||
*/
|
||||
public class AbstractFactoryTest {
|
||||
|
||||
private App app = new App();
|
||||
|
@ -25,6 +25,9 @@ package com.iluwatar.aggregator.microservices;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* Spring Boot EntryPoint Class
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class App {
|
||||
|
||||
|
@ -22,15 +22,18 @@
|
||||
*/
|
||||
package com.iluwatar.aggregator.microservices;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Test Aggregation of domain objects
|
||||
*/
|
||||
public class AggregatorTest {
|
||||
|
||||
@InjectMocks
|
||||
@ -64,4 +67,4 @@ public class AggregatorTest {
|
||||
assertEquals(inventories, testProduct.getProductInventories());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Controller providing endpoints to retrieve information about products
|
||||
*/
|
||||
@RestController
|
||||
public class InformationController {
|
||||
|
||||
|
@ -25,6 +25,9 @@ package com.iluwatar.information.microservice;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test for Information Rest Controller
|
||||
*/
|
||||
public class InformationControllerTest {
|
||||
|
||||
@Test
|
||||
@ -36,4 +39,4 @@ public class InformationControllerTest {
|
||||
Assert.assertEquals("The Product Title.", title);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Controller providing endpoints to retrieve product inventories
|
||||
*/
|
||||
@RestController
|
||||
public class InventoryController {
|
||||
|
||||
|
@ -25,8 +25,10 @@ package com.iluwatar.inventory.microservice;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test Inventory Rest Controller
|
||||
*/
|
||||
public class InventoryControllerTest {
|
||||
|
||||
@Test
|
||||
public void testGetProductInventories() throws Exception {
|
||||
InventoryController inventoryController = new InventoryController();
|
||||
@ -35,4 +37,4 @@ public class InventoryControllerTest {
|
||||
|
||||
Assert.assertEquals(5, numberOfInventories);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,15 +22,18 @@
|
||||
*/
|
||||
package com.iluwatar.api.gateway;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Test API Gateway Pattern
|
||||
*/
|
||||
public class ApiGatewayTest {
|
||||
|
||||
@InjectMocks
|
||||
|
@ -25,6 +25,9 @@ package com.iluwatar.image.microservice;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test for Image Rest Controller
|
||||
*/
|
||||
public class ImageControllerTest {
|
||||
@Test
|
||||
public void testGetImagePath() {
|
||||
|
@ -25,6 +25,10 @@ package com.iluwatar.price.microservice;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Test for Price Rest Controller
|
||||
*/
|
||||
public class PriceControllerTest {
|
||||
@Test
|
||||
public void testgetPrice() {
|
||||
|
@ -25,8 +25,8 @@ package com.iluwatar.async.method.invocation;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
*
|
||||
* AsyncResult interface
|
||||
* @param <T> parameter returned when getValue is invoked
|
||||
*/
|
||||
public interface AsyncResult<T> {
|
||||
|
||||
|
@ -32,10 +32,10 @@
|
||||
Source = https://github.com/checkstyle/checkstyle/tree/master/src/main/resources
|
||||
|
||||
Checkstyle configurartion that checks the Google coding conventions from:
|
||||
|
||||
|
||||
- Google Java Style
|
||||
https://google-styleguide.googlecode.com/svn-history/r130/trunk/javaguide.html
|
||||
|
||||
|
||||
Checkstyle is very configurable. Be sure to read the documentation at
|
||||
http://checkstyle.sf.net (or in your downloaded distribution).
|
||||
|
||||
@ -44,12 +44,12 @@
|
||||
To completely disable a check, just comment it out or delete it from the file.
|
||||
|
||||
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
|
||||
|
||||
|
||||
-->
|
||||
|
||||
<module name="Checker">
|
||||
<property name="charset" value="UTF-8"/>
|
||||
|
||||
|
||||
<property name="fileExtensions" value="java, xml, properties"/>
|
||||
|
||||
<property name="severity" value="error"/>
|
||||
@ -77,7 +77,6 @@
|
||||
<property name="max" value="120"/>
|
||||
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
|
||||
</module>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="OneTopLevelClass"/>
|
||||
<module name="NoLineWrap"/>
|
||||
<module name="EmptyBlock">
|
||||
@ -120,7 +119,7 @@
|
||||
<property name="tokens" value="COMMA"/>
|
||||
<property name="option" value="EOL"/>
|
||||
</module>
|
||||
|
||||
|
||||
<!-- Checks for Naming Conventions. -->
|
||||
<!-- See http://checkstyle.sf.net/config_naming.html -->
|
||||
<module name="ConstantName"/>
|
||||
@ -185,6 +184,10 @@
|
||||
<property name="allowedAnnotations" value="Override, Test, Before, After, Parameters, Given, When, BeforeClass, AfterClass, Parameterized"/>
|
||||
<property name="allowThrowsTagsForSubclasses" value="true"/>
|
||||
</module>
|
||||
<module name="JavadocType">
|
||||
<property name="scope" value="public"/>
|
||||
<property name="allowUnknownTags" value="true"/>
|
||||
</module>
|
||||
<module name="MethodName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
|
||||
<message key="name.invalidPattern"
|
||||
|
@ -22,13 +22,16 @@
|
||||
*/
|
||||
package com.iluwatar.dao;
|
||||
|
||||
/**
|
||||
* Customer Schema SQL Class
|
||||
*/
|
||||
public final class CustomerSchemaSql {
|
||||
|
||||
private CustomerSchemaSql() {}
|
||||
|
||||
public static final String CREATE_SCHEMA_SQL = "CREATE TABLE CUSTOMERS (ID NUMBER, FNAME VARCHAR(100), "
|
||||
public static final String CREATE_SCHEMA_SQL = "CREATE TABLE CUSTOMERS (ID NUMBER, FNAME VARCHAR(100), "
|
||||
+ "LNAME VARCHAR(100))";
|
||||
|
||||
|
||||
public static final String DELETE_SCHEMA_SQL = "DROP TABLE CUSTOMERS";
|
||||
|
||||
|
||||
}
|
||||
|
@ -29,6 +29,9 @@ import static org.junit.Assert.assertNotEquals;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests {@link Customer}.
|
||||
*/
|
||||
public class CustomerTest {
|
||||
|
||||
private Customer customer;
|
||||
|
@ -21,6 +21,9 @@ package com.iluwatar.datamapper;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Class defining Student
|
||||
*/
|
||||
public final class Student implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -32,7 +35,7 @@ public final class Student implements Serializable {
|
||||
|
||||
/**
|
||||
* Use this constructor to create a Student with all details
|
||||
*
|
||||
*
|
||||
* @param studentId as unique student id
|
||||
* @param name as student name
|
||||
* @param grade as respective grade of student
|
||||
@ -46,7 +49,7 @@ public final class Student implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return the student id
|
||||
*/
|
||||
public int getStudentId() {
|
||||
@ -54,7 +57,7 @@ public final class Student implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param studentId as unique student id
|
||||
*/
|
||||
public void setStudentId(final int studentId) {
|
||||
@ -62,7 +65,7 @@ public final class Student implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return name of student
|
||||
*/
|
||||
public String getName() {
|
||||
@ -70,7 +73,7 @@ public final class Student implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param name as 'name' of student
|
||||
*/
|
||||
public void setName(final String name) {
|
||||
@ -78,7 +81,7 @@ public final class Student implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return grade of student
|
||||
*/
|
||||
public char getGrade() {
|
||||
@ -86,7 +89,7 @@ public final class Student implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param grade as 'grade of student'
|
||||
*/
|
||||
public void setGrade(final char grade) {
|
||||
@ -94,7 +97,7 @@ public final class Student implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final Object inputObject) {
|
||||
@ -120,7 +123,7 @@ public final class Student implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
@ -130,7 +133,7 @@ public final class Student implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -20,6 +20,9 @@ package com.iluwatar.datamapper;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Interface lists out the possible behaviour for all possible student mappers
|
||||
*/
|
||||
public interface StudentDataMapper {
|
||||
|
||||
Optional<Student> find(int studentId);
|
||||
|
@ -22,6 +22,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Implementation of Actions on Students Data
|
||||
*/
|
||||
public final class StudentDataMapperImpl implements StudentDataMapper {
|
||||
|
||||
/* Note: Normally this would be in the form of an actual database */
|
||||
|
@ -18,17 +18,21 @@
|
||||
*/
|
||||
package com.iluwatar.datamapper;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests {@link Student}.
|
||||
*/
|
||||
public final class StudentTest {
|
||||
|
||||
@Test
|
||||
/**
|
||||
* This API tests the equality behaviour of Student object
|
||||
* Object Equality should work as per logic defined in equals method
|
||||
*
|
||||
*
|
||||
* @throws Exception if any execution error during test
|
||||
*/
|
||||
public void testEquality() throws Exception {
|
||||
|
@ -22,6 +22,12 @@
|
||||
*/
|
||||
package com.iluwatar.delegation.simple;
|
||||
|
||||
/**
|
||||
* Delegator Class to delegate the implementation of the Printer.
|
||||
* This ensures two things:
|
||||
* - when the actual implementation of the Printer class changes the delegation will still be operational
|
||||
* - the actual benefit is observed when there are more than one implementors and they share a delegation control
|
||||
*/
|
||||
public class PrinterController implements Printer {
|
||||
|
||||
private final Printer printer;
|
||||
|
@ -23,7 +23,9 @@
|
||||
package com.iluwatar.delegation.simple;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Application Test Entry
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
|
@ -22,22 +22,24 @@
|
||||
*/
|
||||
package com.iluwatar.delegation.simple;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.AppenderBase;
|
||||
import com.iluwatar.delegation.simple.printers.CanonPrinter;
|
||||
import com.iluwatar.delegation.simple.printers.EpsonPrinter;
|
||||
import com.iluwatar.delegation.simple.printers.HpPrinter;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Test for Delegation Pattern
|
||||
*/
|
||||
public class DelegateTest {
|
||||
|
||||
private InMemoryAppender appender;
|
||||
@ -78,6 +80,9 @@ public class DelegateTest {
|
||||
assertEquals("Epson Printer : Test Message Printed", appender.getLastMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging Appender
|
||||
*/
|
||||
private class InMemoryAppender extends AppenderBase<ILoggingEvent> {
|
||||
|
||||
private List<ILoggingEvent> log = new LinkedList<>();
|
||||
|
@ -30,6 +30,10 @@ import org.slf4j.LoggerFactory;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* InMemory Log Appender Util.
|
||||
*/
|
||||
public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
|
||||
|
||||
private List<ILoggingEvent> log = new LinkedList<>();
|
||||
|
@ -22,13 +22,14 @@
|
||||
*/
|
||||
package com.iluwatar.doubledispatch;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Date: 12/10/15 - 8:37 PM
|
||||
*
|
||||
* Test for Collision
|
||||
* @param <O> Type of GameObject
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public abstract class CollisionTest<O extends GameObject> {
|
||||
|
@ -22,22 +22,22 @@
|
||||
*/
|
||||
package com.iluwatar.event.aggregator;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Date: 12/12/15 - 10:58 PM
|
||||
*
|
||||
* Tests for Event Emitter
|
||||
* @param <E> Type of Event Emitter
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public abstract class EventEmitterTest<E extends EventEmitter> {
|
||||
@ -115,7 +115,7 @@ public abstract class EventEmitterTest<E extends EventEmitter> {
|
||||
// The observers should not have received any additional events after the week
|
||||
verifyNoMoreInteractions(observers);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Go over every day of the month, and check if the event is emitted on the given day. Use an
|
||||
* event emitter without a default observer
|
||||
|
@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.iluwatar.event.asynchronous;
|
||||
|
||||
/**
|
||||
* Custom Exception Class for Non Existent Event
|
||||
*/
|
||||
public class EventDoesNotExistException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -3398463738273811509L;
|
||||
|
@ -16,6 +16,10 @@
|
||||
*/
|
||||
package com.iluwatar.event.asynchronous;
|
||||
|
||||
/**
|
||||
* Events that fulfill the start stop and list out current status behaviour
|
||||
* follow this interface
|
||||
*/
|
||||
public interface IEvent {
|
||||
|
||||
void start();
|
||||
|
@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.iluwatar.event.asynchronous;
|
||||
|
||||
/**
|
||||
* Type of Exception raised when the Operation being invoked is Invalid
|
||||
*/
|
||||
public class InvalidOperationException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -6191545255213410803L;
|
||||
|
@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.iluwatar.event.asynchronous;
|
||||
|
||||
/**
|
||||
* Type of Exception raised when the Operation being invoked is Long Running
|
||||
*/
|
||||
public class LongRunningEventException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -483423544320148809L;
|
||||
|
@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.iluwatar.event.asynchronous;
|
||||
|
||||
/**
|
||||
* Type of Exception raised when the max number of allowed events is exceeded
|
||||
*/
|
||||
public class MaxNumOfEventsAllowedException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -8430876973516292695L;
|
||||
|
@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.iluwatar.event.asynchronous;
|
||||
|
||||
/**
|
||||
* Interface with listener behaviour related to Thread Completion.
|
||||
*/
|
||||
public interface ThreadCompleteListener {
|
||||
void completedEventHandler(final int eventId);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ package com.iluwatar.eda.framework;
|
||||
/**
|
||||
* This interface can be implemented to handle different types of messages.
|
||||
* Every handler is responsible for a single of type message
|
||||
* @param <E> Handler can handle events of type E
|
||||
*/
|
||||
public interface Handler<E extends Event> {
|
||||
|
||||
@ -35,4 +36,4 @@ public interface Handler<E extends Event> {
|
||||
* @param event the {@link Event} object to be handled.
|
||||
*/
|
||||
void onEvent(E event);
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.factorykit;
|
||||
|
||||
/**
|
||||
* Class representing Axe
|
||||
*/
|
||||
public class Axe implements Weapon {
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.factorykit;
|
||||
|
||||
/**
|
||||
* Class representing Bows
|
||||
*/
|
||||
public class Bow implements Weapon {
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -21,7 +21,9 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package com.iluwatar.factorykit;
|
||||
|
||||
/**
|
||||
* Class representing Spear
|
||||
*/
|
||||
public class Spear implements Weapon {
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -21,7 +21,9 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package com.iluwatar.factorykit;
|
||||
|
||||
/**
|
||||
* Class representing Swords
|
||||
*/
|
||||
public class Sword implements Weapon {
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -25,6 +25,9 @@ package com.iluwatar.factorykit.app;
|
||||
import com.iluwatar.factorykit.App;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Application Test Entrypoint
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* The MIT License
|
||||
* Copyright (c) 2014-2016 Ilkka Seppälä
|
||||
*
|
||||
@ -22,12 +22,19 @@
|
||||
*/
|
||||
package com.iluwatar.factorykit.factorykit;
|
||||
|
||||
import com.iluwatar.factorykit.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.iluwatar.factorykit.Axe;
|
||||
import com.iluwatar.factorykit.Spear;
|
||||
import com.iluwatar.factorykit.Sword;
|
||||
import com.iluwatar.factorykit.Weapon;
|
||||
import com.iluwatar.factorykit.WeaponFactory;
|
||||
import com.iluwatar.factorykit.WeaponType;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
/**
|
||||
* Test Factory Kit Pattern
|
||||
*/
|
||||
public class FactoryKitTest {
|
||||
|
||||
private WeaponFactory factory;
|
||||
|
@ -23,16 +23,18 @@
|
||||
|
||||
package com.iluwatar.featuretoggle.pattern.propertiesversion;
|
||||
|
||||
import com.iluwatar.featuretoggle.pattern.Service;
|
||||
import com.iluwatar.featuretoggle.user.User;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.iluwatar.featuretoggle.pattern.Service;
|
||||
import com.iluwatar.featuretoggle.user.User;
|
||||
import java.util.Properties;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test Properties Toggle
|
||||
*/
|
||||
public class PropertiesFeatureToggleVersionTest {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@ -66,4 +68,4 @@ public class PropertiesFeatureToggleVersionTest {
|
||||
final String welcomeMessage = service.getWelcomeMessage(new User("Jamie No Code"));
|
||||
assertEquals("Welcome to the application.", welcomeMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,15 +22,18 @@
|
||||
*/
|
||||
package com.iluwatar.featuretoggle.pattern.tieredversion;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.iluwatar.featuretoggle.pattern.Service;
|
||||
import com.iluwatar.featuretoggle.user.User;
|
||||
import com.iluwatar.featuretoggle.user.UserGroup;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test Tiered Feature Toggle
|
||||
*/
|
||||
public class TieredFeatureToggleVersionTest {
|
||||
|
||||
final User paidUser = new User("Jamie Coder");
|
||||
@ -61,4 +64,4 @@ public class TieredFeatureToggleVersionTest {
|
||||
public void testIsEnhancedAlwaysTrueAsTiered() throws Exception {
|
||||
assertTrue(service.isEnhanced());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,14 @@
|
||||
*/
|
||||
package com.iluwatar.featuretoggle.user;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test User Group specific feature
|
||||
*/
|
||||
public class UserGroupTest {
|
||||
|
||||
@Test
|
||||
@ -56,4 +59,4 @@ public class UserGroupTest {
|
||||
UserGroup.addUserToPaidGroup(user);
|
||||
UserGroup.addUserToFreeGroup(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import java.util.Iterator;
|
||||
/**
|
||||
* This class is used to realize LazyFluentIterables. It decorates a given iterator. Does not
|
||||
* support consecutive hasNext() calls.
|
||||
* @param <E> Iterable Collection of Elements of Type E
|
||||
*/
|
||||
public abstract class DecoratingIterator<E> implements Iterator<E> {
|
||||
|
||||
@ -43,7 +44,7 @@ public abstract class DecoratingIterator<E> implements Iterator<E> {
|
||||
|
||||
/**
|
||||
* Precomputes and saves the next element of the Iterable. null is considered as end of data.
|
||||
*
|
||||
*
|
||||
* @return true if a next element is available
|
||||
*/
|
||||
@Override
|
||||
@ -54,7 +55,7 @@ public abstract class DecoratingIterator<E> implements Iterator<E> {
|
||||
|
||||
/**
|
||||
* Returns the next element of the Iterable.
|
||||
*
|
||||
*
|
||||
* @return the next element of the Iterable, or null if not present.
|
||||
*/
|
||||
@Override
|
||||
@ -71,7 +72,7 @@ public abstract class DecoratingIterator<E> implements Iterator<E> {
|
||||
/**
|
||||
* Computes the next object of the Iterable. Can be implemented to realize custom behaviour for an
|
||||
* iteration process. null is considered as end of data.
|
||||
*
|
||||
*
|
||||
* @return the next element of the Iterable.
|
||||
*/
|
||||
public abstract E computeNext();
|
||||
|
@ -23,7 +23,9 @@
|
||||
package com.iluwatar.fluentinterface.app;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Application Test Entry
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
|
@ -30,6 +30,9 @@ import org.slf4j.LoggerFactory;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* InMemory Log Appender Util.
|
||||
*/
|
||||
public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
|
||||
|
||||
private List<ILoggingEvent> log = new LinkedList<>();
|
||||
|
@ -28,7 +28,12 @@ import org.slf4j.LoggerFactory;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
|
||||
/**
|
||||
* Guarded Queue is an implementation for Guarded Suspension Pattern
|
||||
* Guarded suspension pattern is used to handle a situation when you want to execute a method
|
||||
* on an object which is not in a proper state.
|
||||
* @see http://java-design-patterns.com/patterns/guarded-suspension/
|
||||
*/
|
||||
public class GuardedQueue {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GuardedQueue.class);
|
||||
private final Queue<Integer> sourceList;
|
||||
|
@ -29,6 +29,9 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Test for Guarded Queue
|
||||
*/
|
||||
public class GuardedQueueTest {
|
||||
private volatile Integer value;
|
||||
|
||||
@ -55,4 +58,4 @@ public class GuardedQueueTest {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -23,12 +23,15 @@
|
||||
package com.iluwatar.hexagonal.domain;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Represents lottery ticket check result.
|
||||
*
|
||||
*/
|
||||
public class LotteryTicketCheckResult {
|
||||
|
||||
/**
|
||||
* Enumeration of Type of Outcomes of a Lottery
|
||||
*/
|
||||
public enum CheckResult { WIN_PRIZE, NO_PRIZE, TICKET_NOT_SUBMITTED }
|
||||
|
||||
private final CheckResult checkResult;
|
||||
@ -41,7 +44,7 @@ public class LotteryTicketCheckResult {
|
||||
checkResult = result;
|
||||
prizeAmount = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@ -56,7 +59,7 @@ public class LotteryTicketCheckResult {
|
||||
public CheckResult getResult() {
|
||||
return checkResult;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return prize amount
|
||||
*/
|
||||
|
@ -30,6 +30,9 @@ import java.util.HashSet;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test Lottery Tickets for equality
|
||||
*/
|
||||
public class LotteryTicketTest {
|
||||
|
||||
@Test
|
||||
|
@ -22,18 +22,19 @@
|
||||
*/
|
||||
package com.iluwatar.interpreter;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Date: 12/14/15 - 11:48 AM
|
||||
*
|
||||
* Test Case for Expressions
|
||||
* @param <E> Type of Expression
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public abstract class ExpressionTest<E extends Expression> {
|
||||
|
@ -22,20 +22,19 @@
|
||||
*/
|
||||
package com.iluwatar.model.view.controller;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.AppenderBase;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Date: 12/20/15 - 2:04 PM
|
||||
*
|
||||
@ -70,6 +69,9 @@ public class GiantViewTest {
|
||||
assertEquals(1, appender.getLogSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging Appender Implementation
|
||||
*/
|
||||
public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
|
||||
private List<ILoggingEvent> log = new LinkedList<>();
|
||||
|
||||
|
@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.monad;
|
||||
|
||||
/**
|
||||
* Enumeration of Types of Sex
|
||||
*/
|
||||
public enum Sex {
|
||||
MALE, FEMALE
|
||||
}
|
||||
|
@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.monad;
|
||||
|
||||
/**
|
||||
* User Definition
|
||||
*/
|
||||
public class User {
|
||||
|
||||
private String name;
|
||||
|
@ -24,6 +24,9 @@ package com.iluwatar.monad;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Application Test
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
|
@ -30,6 +30,9 @@ import org.junit.rules.ExpectedException;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Test for Monad Pattern
|
||||
*/
|
||||
public class MonadTest {
|
||||
|
||||
@Rule
|
||||
|
@ -24,6 +24,9 @@ package com.iluwatar.monostate;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Application Test Entry
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
|
@ -35,47 +35,50 @@ import org.junit.rules.ExpectedException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Test for the mute-idiom pattern
|
||||
*/
|
||||
public class MuteTest {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MuteTest.class);
|
||||
|
||||
private static final String MESSAGE = "should not occur";
|
||||
|
||||
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
|
||||
@Test
|
||||
public void muteShouldRunTheCheckedRunnableAndNotThrowAnyExceptionIfCheckedRunnableDoesNotThrowAnyException() {
|
||||
Mute.mute(() -> methodNotThrowingAnyException());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void muteShouldRethrowUnexpectedExceptionAsAssertionError() throws Exception {
|
||||
exception.expect(AssertionError.class);
|
||||
exception.expectMessage(MESSAGE);
|
||||
|
||||
|
||||
Mute.mute(() -> methodThrowingException());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void loggedMuteShouldRunTheCheckedRunnableAndNotThrowAnyExceptionIfCheckedRunnableDoesNotThrowAnyException() {
|
||||
Mute.loggedMute(() -> methodNotThrowingAnyException());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void loggedMuteShouldLogExceptionTraceBeforeSwallowingIt() throws IOException {
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
System.setErr(new PrintStream(stream));
|
||||
|
||||
|
||||
Mute.loggedMute(() -> methodThrowingException());
|
||||
|
||||
|
||||
assertTrue(new String(stream.toByteArray()).contains(MESSAGE));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void methodNotThrowingAnyException() {
|
||||
LOGGER.info("Executed successfully");
|
||||
}
|
||||
|
||||
|
||||
private void methodThrowingException() throws Exception {
|
||||
throw new Exception(MESSAGE);
|
||||
}
|
||||
|
@ -25,10 +25,13 @@ package com.iluwatar.mutex;
|
||||
import org.junit.Test;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Application Test Entrypoint
|
||||
*/
|
||||
public class AppTest{
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
String[] args = {};
|
||||
App.main(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@
|
||||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
@ -21,6 +21,10 @@ import org.apache.isis.applib.annotation.HomePage;
|
||||
import org.apache.isis.applib.annotation.NatureOfService;
|
||||
import org.apache.isis.applib.annotation.SemanticsOf;
|
||||
|
||||
/**
|
||||
* HomePage Domain Service
|
||||
* @see HomePageViewModel linked view to HomePage
|
||||
*/
|
||||
@DomainService(nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY)
|
||||
public class HomePageService {
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
@ -21,6 +21,11 @@ import org.apache.isis.applib.annotation.ViewModel;
|
||||
import domainapp.dom.modules.simple.SimpleObject;
|
||||
import domainapp.dom.modules.simple.SimpleObjects;
|
||||
|
||||
/**
|
||||
* Model linked to the HomePage
|
||||
* The underlying layout is specified by json
|
||||
* @see HomePageService - Service Linked to the HomePage
|
||||
*/
|
||||
@ViewModel
|
||||
public class HomePageViewModel {
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
@ -33,6 +33,9 @@ import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
|
||||
import org.apache.isis.applib.services.i18n.TranslatableString;
|
||||
import org.apache.isis.applib.util.ObjectContracts;
|
||||
|
||||
/**
|
||||
* Definition of a Simple Object
|
||||
*/
|
||||
@javax.jdo.annotations.PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "simple",
|
||||
table = "SimpleObject")
|
||||
@javax.jdo.annotations.DatastoreIdentity(
|
||||
@ -53,7 +56,7 @@ public class SimpleObject implements Comparable<SimpleObject> {
|
||||
// region > name (property)
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
// region > identificatiom
|
||||
public TranslatableString title() {
|
||||
return TranslatableString.tr("Object: {name}", "name", getName());
|
||||
@ -74,6 +77,9 @@ public class SimpleObject implements Comparable<SimpleObject> {
|
||||
|
||||
// region > updateName (action)
|
||||
|
||||
/**
|
||||
* Event used to update the Name in the Domain
|
||||
*/
|
||||
public static class UpdateNameDomainEvent extends ActionDomainEvent<SimpleObject> {
|
||||
public UpdateNameDomainEvent(final SimpleObject source, final Identifier identifier,
|
||||
final Object... arguments) {
|
||||
|
@ -4,9 +4,9 @@
|
||||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
@ -30,6 +30,9 @@ import org.apache.isis.applib.query.QueryDefault;
|
||||
import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
|
||||
import org.apache.isis.applib.services.i18n.TranslatableString;
|
||||
|
||||
/**
|
||||
* Domain Service for Simple Objects
|
||||
*/
|
||||
@DomainService(repositoryFor = SimpleObject.class)
|
||||
@DomainServiceLayout(menuOrder = "10")
|
||||
public class SimpleObjects {
|
||||
@ -69,6 +72,9 @@ public class SimpleObjects {
|
||||
|
||||
// endregion
|
||||
|
||||
/**
|
||||
* Create Domain Event on SimpleObjects
|
||||
*/
|
||||
// region > create (action)
|
||||
public static class CreateDomainEvent extends ActionDomainEvent<SimpleObjects> {
|
||||
public CreateDomainEvent(final SimpleObjects source, final Identifier identifier,
|
||||
|
@ -14,11 +14,14 @@
|
||||
*/
|
||||
package domainapp.dom.modules.simple;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test for SimpleObject
|
||||
*/
|
||||
public class SimpleObjectTest {
|
||||
|
||||
SimpleObject simpleObject;
|
||||
@ -28,6 +31,9 @@ public class SimpleObjectTest {
|
||||
simpleObject = new SimpleObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for Names for SimpleObjects
|
||||
*/
|
||||
public static class Name extends SimpleObjectTest {
|
||||
|
||||
@Test
|
||||
|
@ -14,10 +14,13 @@
|
||||
*/
|
||||
package domainapp.dom.modules.simple;
|
||||
|
||||
import java.util.List;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.isis.applib.DomainObjectContainer;
|
||||
import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
|
||||
import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Sequence;
|
||||
import org.jmock.auto.Mock;
|
||||
@ -25,12 +28,9 @@ import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.isis.applib.DomainObjectContainer;
|
||||
import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
|
||||
import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test for SimpleObjects
|
||||
*/
|
||||
public class SimpleObjectsTest {
|
||||
|
||||
@Rule
|
||||
@ -47,6 +47,9 @@ public class SimpleObjectsTest {
|
||||
simpleObjects.container = mockContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Creation of Simple Objects
|
||||
*/
|
||||
public static class Create extends SimpleObjectsTest {
|
||||
|
||||
@Test
|
||||
@ -77,6 +80,9 @@ public class SimpleObjectsTest {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Listing of Simple Objects
|
||||
*/
|
||||
public static class ListAll extends SimpleObjectsTest {
|
||||
|
||||
@Test
|
||||
|
@ -4,9 +4,9 @@
|
||||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
@ -20,6 +20,9 @@ import org.apache.isis.applib.fixturescripts.FixtureScript;
|
||||
import domainapp.dom.modules.simple.SimpleObject;
|
||||
import domainapp.dom.modules.simple.SimpleObjects;
|
||||
|
||||
/**
|
||||
* Fixture to create a simple object
|
||||
*/
|
||||
public class SimpleObjectCreate extends FixtureScript {
|
||||
|
||||
// endregion
|
||||
@ -45,7 +48,7 @@ public class SimpleObjectCreate extends FixtureScript {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The created simple object (output).
|
||||
*/
|
||||
@ -65,5 +68,5 @@ public class SimpleObjectCreate extends FixtureScript {
|
||||
// also make available to UI
|
||||
ec.addResult(this, simpleObject);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,9 @@
|
||||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
@ -18,6 +18,9 @@ package domainapp.fixture.modules.simple;
|
||||
import org.apache.isis.applib.fixturescripts.FixtureScript;
|
||||
import org.apache.isis.applib.services.jdosupport.IsisJdoSupport;
|
||||
|
||||
/**
|
||||
* TearDown/Cleanup for SimpleObjects
|
||||
*/
|
||||
public class SimpleObjectsTearDown extends FixtureScript {
|
||||
|
||||
@javax.inject.Inject
|
||||
@ -27,5 +30,5 @@ public class SimpleObjectsTearDown extends FixtureScript {
|
||||
protected void execute(ExecutionContext executionContext) {
|
||||
isisJdoSupport.executeUpdate("delete from \"simple\".\"SimpleObject\"");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,9 @@
|
||||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
@ -27,6 +27,10 @@ import domainapp.dom.modules.simple.SimpleObject;
|
||||
import domainapp.fixture.modules.simple.SimpleObjectCreate;
|
||||
import domainapp.fixture.modules.simple.SimpleObjectsTearDown;
|
||||
|
||||
|
||||
/**
|
||||
* Create a bunch of simple Objects
|
||||
*/
|
||||
public class RecreateSimpleObjects extends FixtureScript {
|
||||
|
||||
public final List<String> names = Collections.unmodifiableList(Arrays.asList("Foo", "Bar", "Baz",
|
||||
@ -43,7 +47,7 @@ public class RecreateSimpleObjects extends FixtureScript {
|
||||
public RecreateSimpleObjects() {
|
||||
withDiscoverability(Discoverability.DISCOVERABLE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The number of objects to create, up to 10; optional, defaults to 3.
|
||||
*/
|
||||
@ -55,7 +59,7 @@ public class RecreateSimpleObjects extends FixtureScript {
|
||||
this.number = number;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The simpleobjects created by this fixture (output).
|
||||
*/
|
||||
|
@ -4,9 +4,9 @@
|
||||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
@ -19,6 +19,9 @@ import org.apache.isis.core.integtestsupport.IsisSystemForTest;
|
||||
import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusPersistenceMechanismInstaller;
|
||||
import org.apache.isis.objectstore.jdo.datanucleus.IsisConfigurationForJdoIntegTests;
|
||||
|
||||
/**
|
||||
* Initializer for the Simple App
|
||||
*/
|
||||
public final class SimpleAppSystemInitializer {
|
||||
|
||||
private SimpleAppSystemInitializer() {
|
||||
|
@ -21,6 +21,9 @@ import cucumber.api.java.After;
|
||||
import cucumber.api.java.Before;
|
||||
import domainapp.integtests.bootstrap.SimpleAppSystemInitializer;
|
||||
|
||||
/**
|
||||
* BootStrapping IntegrationTesting Before and After Steps
|
||||
*/
|
||||
public class BootstrappingGlue extends CukeGlueAbstract {
|
||||
|
||||
@Before(value = {"@integration"}, order = 100)
|
||||
|
@ -19,6 +19,9 @@ import org.apache.isis.core.specsupport.specs.CukeGlueAbstract;
|
||||
import cucumber.api.java.Before;
|
||||
import domainapp.fixture.scenarios.RecreateSimpleObjects;
|
||||
|
||||
/**
|
||||
* Test Execution to append a fixture of SimpleObjects
|
||||
*/
|
||||
public class CatalogOfFixturesGlue extends CukeGlueAbstract {
|
||||
|
||||
@Before(value = {"@integration", "@SimpleObjectsFixture"}, order = 20000)
|
||||
|
@ -14,18 +14,20 @@
|
||||
*/
|
||||
package domainapp.integtests.specglue.modules.simple;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.isis.core.specsupport.specs.CukeGlueAbstract;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import cucumber.api.java.en.Given;
|
||||
import cucumber.api.java.en.When;
|
||||
import domainapp.dom.modules.simple.SimpleObject;
|
||||
import domainapp.dom.modules.simple.SimpleObjects;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.apache.isis.core.specsupport.specs.CukeGlueAbstract;
|
||||
|
||||
/**
|
||||
* Test Simple Object Operations
|
||||
*/
|
||||
public class SimpleObjectGlue extends CukeGlueAbstract {
|
||||
|
||||
@Given("^there are.* (\\d+) simple objects$")
|
||||
|
@ -25,6 +25,9 @@ import org.apache.isis.core.integtestsupport.scenarios.ScenarioExecutionForInteg
|
||||
|
||||
import domainapp.integtests.bootstrap.SimpleAppSystemInitializer;
|
||||
|
||||
/**
|
||||
* SimpleApp Integration Tests will implement this Abstract Class.
|
||||
*/
|
||||
public abstract class SimpleAppIntegTest extends IntegrationTestAbstract {
|
||||
|
||||
@BeforeClass
|
||||
@ -35,5 +38,4 @@ public abstract class SimpleAppIntegTest extends IntegrationTestAbstract {
|
||||
// instantiating will install onto ThreadLocal
|
||||
new ScenarioExecutionForIntegration();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,21 +18,22 @@
|
||||
*/
|
||||
package domainapp.integtests.tests.modules.simple;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.isis.applib.DomainObjectContainer;
|
||||
import org.apache.isis.applib.fixturescripts.FixtureScripts;
|
||||
import org.apache.isis.applib.services.wrapper.DisabledException;
|
||||
import org.apache.isis.applib.services.wrapper.InvalidException;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import domainapp.dom.modules.simple.SimpleObject;
|
||||
import domainapp.fixture.scenarios.RecreateSimpleObjects;
|
||||
import domainapp.integtests.tests.SimpleAppIntegTest;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import javax.inject.Inject;
|
||||
import org.apache.isis.applib.DomainObjectContainer;
|
||||
import org.apache.isis.applib.fixturescripts.FixtureScripts;
|
||||
import org.apache.isis.applib.services.wrapper.DisabledException;
|
||||
import org.apache.isis.applib.services.wrapper.InvalidException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test Fixtures with Simple Objects
|
||||
*/
|
||||
public class SimpleObjectIntegTest extends SimpleAppIntegTest {
|
||||
|
||||
@Inject
|
||||
@ -54,6 +55,9 @@ public class SimpleObjectIntegTest extends SimpleAppIntegTest {
|
||||
simpleObjectWrapped = wrap(simpleObjectPojo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Object Name accessibility
|
||||
*/
|
||||
public static class Name extends SimpleObjectIntegTest {
|
||||
|
||||
@Test
|
||||
@ -75,6 +79,9 @@ public class SimpleObjectIntegTest extends SimpleAppIntegTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Validation of SimpleObject Names
|
||||
*/
|
||||
public static class UpdateName extends SimpleObjectIntegTest {
|
||||
|
||||
@Test
|
||||
@ -99,6 +106,9 @@ public class SimpleObjectIntegTest extends SimpleAppIntegTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ContainerTitle generation based on SimpleObject Name
|
||||
*/
|
||||
public static class Title extends SimpleObjectIntegTest {
|
||||
|
||||
@Inject
|
||||
@ -117,4 +127,4 @@ public class SimpleObjectIntegTest extends SimpleAppIntegTest {
|
||||
assertThat(title).isEqualTo("Object: " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,28 +18,27 @@
|
||||
*/
|
||||
package domainapp.integtests.tests.modules.simple;
|
||||
|
||||
import java.sql.SQLIntegrityConstraintViolationException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.isis.applib.fixturescripts.FixtureScript;
|
||||
import org.apache.isis.applib.fixturescripts.FixtureScripts;
|
||||
|
||||
import domainapp.dom.modules.simple.SimpleObject;
|
||||
import domainapp.dom.modules.simple.SimpleObjects;
|
||||
import domainapp.fixture.modules.simple.SimpleObjectsTearDown;
|
||||
import domainapp.fixture.scenarios.RecreateSimpleObjects;
|
||||
import domainapp.integtests.tests.SimpleAppIntegTest;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.sql.SQLIntegrityConstraintViolationException;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import org.apache.isis.applib.fixturescripts.FixtureScript;
|
||||
import org.apache.isis.applib.fixturescripts.FixtureScripts;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Fixture Pattern Integration Test
|
||||
*/
|
||||
public class SimpleObjectsIntegTest extends SimpleAppIntegTest {
|
||||
|
||||
@Inject
|
||||
@ -47,6 +46,9 @@ public class SimpleObjectsIntegTest extends SimpleAppIntegTest {
|
||||
@Inject
|
||||
SimpleObjects simpleObjects;
|
||||
|
||||
/**
|
||||
* Test Listing of All Simple Objects
|
||||
*/
|
||||
public static class ListAll extends SimpleObjectsIntegTest {
|
||||
|
||||
@Test
|
||||
@ -83,6 +85,10 @@ public class SimpleObjectsIntegTest extends SimpleAppIntegTest {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test Creation of Simple Objects
|
||||
*/
|
||||
public static class Create extends SimpleObjectsIntegTest {
|
||||
|
||||
@Test
|
||||
@ -140,4 +146,4 @@ public class SimpleObjectsIntegTest extends SimpleAppIntegTest {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.objectmother;
|
||||
|
||||
/**
|
||||
* Defines all attributes and behaviour related to the King
|
||||
*/
|
||||
public class King implements Royalty {
|
||||
boolean isDrunk = false;
|
||||
boolean isHappy = false;
|
||||
@ -45,11 +48,11 @@ public class King implements Royalty {
|
||||
public void makeUnhappy() {
|
||||
isHappy = false;
|
||||
}
|
||||
|
||||
|
||||
public boolean isHappy() {
|
||||
return isHappy;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to flirt to a queen.
|
||||
* @param queen Queen which should be flirted.
|
||||
@ -61,6 +64,6 @@ public class King implements Royalty {
|
||||
} else {
|
||||
this.makeHappy();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.objectmother;
|
||||
|
||||
/**
|
||||
* Defines all attributes and behaviour related to the Queen
|
||||
*/
|
||||
public class Queen implements Royalty {
|
||||
private boolean isDrunk = false;
|
||||
private boolean isHappy = false;
|
||||
@ -46,7 +49,7 @@ public class Queen implements Royalty {
|
||||
public void makeUnhappy() {
|
||||
isHappy = false;
|
||||
}
|
||||
|
||||
|
||||
public boolean isFlirty() {
|
||||
return isFlirty;
|
||||
}
|
||||
@ -54,7 +57,7 @@ public class Queen implements Royalty {
|
||||
public void setFlirtiness(boolean flirtiness) {
|
||||
this.isFlirty = flirtiness;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method which is called when the king is flirting to a queen.
|
||||
* @param king King who initialized the flirt.
|
||||
|
@ -22,12 +22,15 @@
|
||||
*/
|
||||
package com.iluwatar.objectmother;
|
||||
|
||||
/**
|
||||
* Interface contracting Royalty Behaviour
|
||||
*/
|
||||
public interface Royalty {
|
||||
void makeDrunk();
|
||||
|
||||
|
||||
void makeSober();
|
||||
|
||||
|
||||
void makeHappy();
|
||||
|
||||
|
||||
void makeUnhappy();
|
||||
}
|
||||
|
@ -22,8 +22,11 @@
|
||||
*/
|
||||
package com.iluwatar.objectmother;
|
||||
|
||||
/**
|
||||
* Object Mother Pattern generating Royalty Types
|
||||
*/
|
||||
public final class RoyaltyObjectMother {
|
||||
|
||||
|
||||
/**
|
||||
* Method to create a sober and unhappy king. The standard paramters are set.
|
||||
* @return An instance of {@link com.iluwatar.objectmother.King} with the standard properties.
|
||||
@ -31,7 +34,7 @@ public final class RoyaltyObjectMother {
|
||||
public static King createSoberUnhappyKing() {
|
||||
return new King();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method of the object mother to create a drunk king.
|
||||
* @return A drunk {@link com.iluwatar.objectmother.King}.
|
||||
@ -41,7 +44,7 @@ public final class RoyaltyObjectMother {
|
||||
king.makeDrunk();
|
||||
return king;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to create a happy king.
|
||||
* @return A happy {@link com.iluwatar.objectmother.King}.
|
||||
@ -51,7 +54,7 @@ public final class RoyaltyObjectMother {
|
||||
king.makeHappy();
|
||||
return king;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to create a happy and drunk king.
|
||||
* @return A drunk and happy {@link com.iluwatar.objectmother.King}.
|
||||
@ -62,7 +65,7 @@ public final class RoyaltyObjectMother {
|
||||
king.makeDrunk();
|
||||
return king;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to create a flirty queen.
|
||||
* @return A flirty {@link com.iluwatar.objectmother.Queen}.
|
||||
@ -72,7 +75,7 @@ public final class RoyaltyObjectMother {
|
||||
queen.setFlirtiness(true);
|
||||
return queen;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to create a not flirty queen.
|
||||
* @return A not flirty {@link com.iluwatar.objectmother.Queen}.
|
||||
|
@ -33,8 +33,11 @@ import com.iluwatar.objectmother.Queen;
|
||||
import com.iluwatar.objectmother.Royalty;
|
||||
import com.iluwatar.objectmother.RoyaltyObjectMother;
|
||||
|
||||
/**
|
||||
* Test Generation of Royalty Types using the object-mother
|
||||
*/
|
||||
public class RoyaltyObjectMotherTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void unsuccessfulKingFlirt() {
|
||||
King soberUnhappyKing = RoyaltyObjectMother.createSoberUnhappyKing();
|
||||
@ -42,7 +45,7 @@ public class RoyaltyObjectMotherTest {
|
||||
soberUnhappyKing.flirt(flirtyQueen);
|
||||
assertFalse(soberUnhappyKing.isHappy());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void queenIsBlockingFlirtCauseDrunkKing() {
|
||||
King drunkUnhappyKing = RoyaltyObjectMother.createDrunkKing();
|
||||
@ -50,7 +53,7 @@ public class RoyaltyObjectMotherTest {
|
||||
drunkUnhappyKing.flirt(notFlirtyQueen);
|
||||
assertFalse(drunkUnhappyKing.isHappy());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void queenIsBlockingFlirt() {
|
||||
King soberHappyKing = RoyaltyObjectMother.createHappyKing();
|
||||
@ -58,7 +61,7 @@ public class RoyaltyObjectMotherTest {
|
||||
soberHappyKing.flirt(notFlirtyQueen);
|
||||
assertFalse(soberHappyKing.isHappy());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void successfullKingFlirt() {
|
||||
King soberHappyKing = RoyaltyObjectMother.createHappyKing();
|
||||
@ -66,7 +69,7 @@ public class RoyaltyObjectMotherTest {
|
||||
soberHappyKing.flirt(flirtyQueen);
|
||||
assertTrue(soberHappyKing.isHappy());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testQueenType() {
|
||||
Royalty flirtyQueen = RoyaltyObjectMother.createFlirtyQueen();
|
||||
@ -74,7 +77,7 @@ public class RoyaltyObjectMotherTest {
|
||||
assertEquals(flirtyQueen.getClass(), Queen.class);
|
||||
assertEquals(notFlirtyQueen.getClass(), Queen.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testKingType() {
|
||||
Royalty drunkKing = RoyaltyObjectMother.createDrunkKing();
|
||||
|
@ -26,8 +26,8 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* Generic object pool
|
||||
* @param <T> Type T of Object in the Pool
|
||||
*/
|
||||
public abstract class ObjectPool<T> {
|
||||
|
||||
|
@ -23,8 +23,10 @@
|
||||
package com.iluwatar.observer.generic;
|
||||
|
||||
/**
|
||||
*
|
||||
* Observer
|
||||
* @param <S> Observable
|
||||
* @param <O> Observer
|
||||
* @param <A> Action
|
||||
*/
|
||||
public interface Observer<S extends Observable<S, O, A>, O extends Observer<S, O, A>, A> {
|
||||
|
||||
|
@ -22,18 +22,18 @@
|
||||
*/
|
||||
package com.iluwatar.observer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.iluwatar.observer.utils.InMemoryAppender;
|
||||
import java.util.function.Supplier;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Date: 12/27/15 - 11:44 AM
|
||||
*
|
||||
* Weather Observer Tests
|
||||
* @param <O> Type of WeatherObserver
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public abstract class WeatherObserverTest<O extends WeatherObserver> {
|
||||
|
@ -22,19 +22,19 @@
|
||||
*/
|
||||
package com.iluwatar.observer.generic;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.iluwatar.observer.WeatherType;
|
||||
import com.iluwatar.observer.utils.InMemoryAppender;
|
||||
import java.util.function.Supplier;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Date: 12/27/15 - 11:44 AM
|
||||
*
|
||||
* Test for Observers
|
||||
* @param <O> Type of Observer
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public abstract class ObserverTest<O extends Observer> {
|
||||
|
@ -30,6 +30,9 @@ import org.slf4j.LoggerFactory;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* InMemory Log Appender Util.
|
||||
*/
|
||||
public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
|
||||
private List<ILoggingEvent> log = new LinkedList<>();
|
||||
|
||||
|
@ -23,15 +23,17 @@
|
||||
package com.iluwatar.pageobject;
|
||||
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.gargoylesoftware.htmlunit.WebClient;
|
||||
import com.iluwatar.pageobject.pages.AlbumListPage;
|
||||
import com.iluwatar.pageobject.pages.AlbumPage;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
/**
|
||||
* Test Album Selection and Album Listing
|
||||
*/
|
||||
public class AlbumListPageTest {
|
||||
|
||||
private AlbumListPage albumListPage = new AlbumListPage(new WebClient());
|
||||
|
@ -22,14 +22,17 @@
|
||||
*/
|
||||
package com.iluwatar.pageobject;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.gargoylesoftware.htmlunit.WebClient;
|
||||
import com.iluwatar.pageobject.pages.AlbumListPage;
|
||||
import com.iluwatar.pageobject.pages.AlbumPage;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test Album Page Operations
|
||||
*/
|
||||
public class AlbumPageTest {
|
||||
|
||||
private AlbumPage albumPage = new AlbumPage(new WebClient());
|
||||
|
@ -22,14 +22,17 @@
|
||||
*/
|
||||
package com.iluwatar.pageobject;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.gargoylesoftware.htmlunit.WebClient;
|
||||
import com.iluwatar.pageobject.pages.AlbumListPage;
|
||||
import com.iluwatar.pageobject.pages.LoginPage;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test Login Page Object
|
||||
*/
|
||||
public class LoginPageTest {
|
||||
|
||||
private LoginPage loginPage = new LoginPage(new WebClient());
|
||||
|
@ -63,6 +63,9 @@ public interface Message {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Enumeration of Type of Headers
|
||||
*/
|
||||
public enum Headers {
|
||||
DATE, SENDER
|
||||
}
|
||||
|
@ -30,6 +30,9 @@ import org.slf4j.LoggerFactory;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* InMemory Log Appender Util.
|
||||
*/
|
||||
public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
|
||||
private List<ILoggingEvent> log = new LinkedList<>();
|
||||
|
||||
|
@ -39,6 +39,9 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Utility to perform various operations
|
||||
*/
|
||||
public class Utility {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Utility.class);
|
||||
|
@ -30,6 +30,9 @@ import java.util.Map;
|
||||
*/
|
||||
public class Character implements Prototype {
|
||||
|
||||
/**
|
||||
* Enumeration of Character types
|
||||
*/
|
||||
public enum Type {
|
||||
WARRIOR, MAGE, ROGUE
|
||||
}
|
||||
|
@ -22,21 +22,20 @@
|
||||
*/
|
||||
package com.iluwatar.prototype;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
/**
|
||||
* Date: 12/28/15 - 8:45 PM
|
||||
*
|
||||
* @param <P> Prototype
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
|
@ -30,6 +30,10 @@ import org.slf4j.LoggerFactory;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* InMemory Log Appender Util.
|
||||
*/
|
||||
public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
|
||||
private List<ILoggingEvent> log = new LinkedList<>();
|
||||
|
||||
|
@ -30,6 +30,9 @@ import org.slf4j.LoggerFactory;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* InMemory Log Appender Util.
|
||||
*/
|
||||
public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
|
||||
private List<ILoggingEvent> log = new LinkedList<>();
|
||||
|
||||
|
@ -34,6 +34,9 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
*/
|
||||
public class PersonSpecifications {
|
||||
|
||||
/**
|
||||
* Specifications stating the Between (From - To) Age Specification
|
||||
*/
|
||||
public static class AgeBetweenSpec implements Specification<Person> {
|
||||
|
||||
private int from;
|
||||
|
@ -22,19 +22,18 @@
|
||||
*/
|
||||
package com.iluwatar.resource.acquisition.is.initialization;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.AppenderBase;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Date: 12/28/15 - 9:31 PM
|
||||
*
|
||||
@ -64,6 +63,9 @@ public class ClosableTest {
|
||||
assertTrue(appender.logContains("Sliding door closes."));
|
||||
}
|
||||
|
||||
/**
|
||||
* Logging Appender Implementation
|
||||
*/
|
||||
public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
|
||||
private List<ILoggingEvent> log = new LinkedList<>();
|
||||
|
||||
|
@ -23,36 +23,39 @@
|
||||
package com.iluwatar.semaphore;
|
||||
|
||||
/**
|
||||
* Fruit is a resource stored in a FruitBowl.
|
||||
* Fruit is a resource stored in a FruitBowl.
|
||||
*/
|
||||
public class Fruit {
|
||||
|
||||
/**
|
||||
* Enumeration of Fruit Types
|
||||
*/
|
||||
public static enum FruitType {
|
||||
ORANGE, APPLE, LEMON
|
||||
}
|
||||
|
||||
|
||||
private FruitType type;
|
||||
|
||||
|
||||
public Fruit(FruitType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
public FruitType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* toString method
|
||||
*/
|
||||
*/
|
||||
public String toString() {
|
||||
switch (type) {
|
||||
case ORANGE:
|
||||
return "Orange";
|
||||
case APPLE:
|
||||
case APPLE:
|
||||
return "Apple";
|
||||
case LEMON:
|
||||
case LEMON:
|
||||
return "Lemon";
|
||||
default:
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,13 @@ package com.iluwatar.semaphore;
|
||||
import org.junit.Test;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Application Test Entrypoint
|
||||
*/
|
||||
public class AppTest{
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
String[] args = {};
|
||||
App.main(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,23 +22,23 @@
|
||||
*/
|
||||
package com.iluwatar.servicelayer.common;
|
||||
|
||||
import com.iluwatar.servicelayer.hibernate.HibernateUtil;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import com.iluwatar.servicelayer.hibernate.HibernateUtil;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Date: 12/28/15 - 10:53 PM
|
||||
*
|
||||
* Test for Base Data Access Objects
|
||||
* @param <E> Type of Base Entity
|
||||
* @param <D> Type of Dao Base Implementation
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>> {
|
||||
@ -142,4 +142,4 @@ public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>
|
||||
assertEquals(expectedName, entity.toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,8 @@
|
||||
*/
|
||||
package com.iluwatar.singleton;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -31,9 +32,7 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* This class provides several test case that test singleton construction.
|
||||
@ -43,7 +42,7 @@ import static org.junit.Assert.assertSame;
|
||||
* the same when called in the DIFFERENT thread.
|
||||
*
|
||||
* Date: 12/29/15 - 19:25 PM
|
||||
*
|
||||
* @param <S> Supplier method generating singletons
|
||||
* @author Jeroen Meulemeester
|
||||
* @author Richard Jones
|
||||
*/
|
||||
|
@ -22,23 +22,22 @@
|
||||
*/
|
||||
package com.iluwatar.templatemethod;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.AppenderBase;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Date: 12/30/15 - 18:12 PM
|
||||
*
|
||||
* @param <M> Type of StealingMethod
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public abstract class StealingMethodTest<M extends StealingMethod> {
|
||||
|
@ -22,7 +22,8 @@
|
||||
*/
|
||||
package com.iluwatar.threadpool;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -34,13 +35,12 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Date: 12/30/15 - 18:22 PM
|
||||
*
|
||||
* Test for Tasks using a Thread Pool
|
||||
* @param <T> Type of Task
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public abstract class TaskTest<T extends Task> {
|
||||
@ -140,4 +140,4 @@ public abstract class TaskTest<T extends Task> {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user