Merge pull request #548 from muditporwal/master

Checkstyle improvements #539 : Added JavaDocType Rule
This commit is contained in:
Ilkka Seppälä 2017-04-01 14:45:52 +03:00 committed by GitHub
commit 3f272bf291
103 changed files with 575 additions and 282 deletions

View File

@ -28,6 +28,9 @@ import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
/**
* Test for abstract factory
*/
public class AbstractFactoryTest { public class AbstractFactoryTest {
private App app = new App(); private App app = new App();

View File

@ -25,6 +25,9 @@ package com.iluwatar.aggregator.microservices;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Spring Boot EntryPoint Class
*/
@SpringBootApplication @SpringBootApplication
public class App { public class App {

View File

@ -22,15 +22,18 @@
*/ */
package com.iluwatar.aggregator.microservices; package com.iluwatar.aggregator.microservices;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
import static org.junit.Assert.assertEquals; /**
import static org.mockito.Mockito.when; * Test Aggregation of domain objects
*/
public class AggregatorTest { public class AggregatorTest {
@InjectMocks @InjectMocks
@ -64,4 +67,4 @@ public class AggregatorTest {
assertEquals(inventories, testProduct.getProductInventories()); assertEquals(inventories, testProduct.getProductInventories());
} }
} }

View File

@ -26,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/**
* Controller providing endpoints to retrieve information about products
*/
@RestController @RestController
public class InformationController { public class InformationController {

View File

@ -25,6 +25,9 @@ package com.iluwatar.information.microservice;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/**
* Test for Information Rest Controller
*/
public class InformationControllerTest { public class InformationControllerTest {
@Test @Test
@ -36,4 +39,4 @@ public class InformationControllerTest {
Assert.assertEquals("The Product Title.", title); Assert.assertEquals("The Product Title.", title);
} }
} }

View File

@ -26,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/**
* Controller providing endpoints to retrieve product inventories
*/
@RestController @RestController
public class InventoryController { public class InventoryController {

View File

@ -25,8 +25,10 @@ package com.iluwatar.inventory.microservice;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/**
* Test Inventory Rest Controller
*/
public class InventoryControllerTest { public class InventoryControllerTest {
@Test @Test
public void testGetProductInventories() throws Exception { public void testGetProductInventories() throws Exception {
InventoryController inventoryController = new InventoryController(); InventoryController inventoryController = new InventoryController();
@ -35,4 +37,4 @@ public class InventoryControllerTest {
Assert.assertEquals(5, numberOfInventories); Assert.assertEquals(5, numberOfInventories);
} }
} }

View File

@ -22,15 +22,18 @@
*/ */
package com.iluwatar.api.gateway; package com.iluwatar.api.gateway;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
import static org.junit.Assert.assertEquals; /**
import static org.mockito.Mockito.when; * Test API Gateway Pattern
*/
public class ApiGatewayTest { public class ApiGatewayTest {
@InjectMocks @InjectMocks

View File

@ -25,6 +25,9 @@ package com.iluwatar.image.microservice;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/**
* Test for Image Rest Controller
*/
public class ImageControllerTest { public class ImageControllerTest {
@Test @Test
public void testGetImagePath() { public void testGetImagePath() {

View File

@ -25,6 +25,10 @@ package com.iluwatar.price.microservice;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/**
* Test for Price Rest Controller
*/
public class PriceControllerTest { public class PriceControllerTest {
@Test @Test
public void testgetPrice() { public void testgetPrice() {

View File

@ -25,8 +25,8 @@ package com.iluwatar.async.method.invocation;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
/** /**
*
* AsyncResult interface * AsyncResult interface
* @param <T> parameter returned when getValue is invoked
*/ */
public interface AsyncResult<T> { public interface AsyncResult<T> {

View File

@ -32,10 +32,10 @@
Source = https://github.com/checkstyle/checkstyle/tree/master/src/main/resources Source = https://github.com/checkstyle/checkstyle/tree/master/src/main/resources
Checkstyle configurartion that checks the Google coding conventions from: Checkstyle configurartion that checks the Google coding conventions from:
- Google Java Style - Google Java Style
https://google-styleguide.googlecode.com/svn-history/r130/trunk/javaguide.html https://google-styleguide.googlecode.com/svn-history/r130/trunk/javaguide.html
Checkstyle is very configurable. Be sure to read the documentation at Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution). 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. To completely disable a check, just comment it out or delete it from the file.
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov. Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
--> -->
<module name="Checker"> <module name="Checker">
<property name="charset" value="UTF-8"/> <property name="charset" value="UTF-8"/>
<property name="fileExtensions" value="java, xml, properties"/> <property name="fileExtensions" value="java, xml, properties"/>
<property name="severity" value="error"/> <property name="severity" value="error"/>
@ -77,7 +77,6 @@
<property name="max" value="120"/> <property name="max" value="120"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/> <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module> </module>
<module name="AvoidStarImport"/>
<module name="OneTopLevelClass"/> <module name="OneTopLevelClass"/>
<module name="NoLineWrap"/> <module name="NoLineWrap"/>
<module name="EmptyBlock"> <module name="EmptyBlock">
@ -120,7 +119,7 @@
<property name="tokens" value="COMMA"/> <property name="tokens" value="COMMA"/>
<property name="option" value="EOL"/> <property name="option" value="EOL"/>
</module> </module>
<!-- Checks for Naming Conventions. --> <!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html --> <!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="ConstantName"/> <module name="ConstantName"/>
@ -185,6 +184,10 @@
<property name="allowedAnnotations" value="Override, Test, Before, After, Parameters, Given, When, BeforeClass, AfterClass, Parameterized"/> <property name="allowedAnnotations" value="Override, Test, Before, After, Parameters, Given, When, BeforeClass, AfterClass, Parameterized"/>
<property name="allowThrowsTagsForSubclasses" value="true"/> <property name="allowThrowsTagsForSubclasses" value="true"/>
</module> </module>
<module name="JavadocType">
<property name="scope" value="public"/>
<property name="allowUnknownTags" value="true"/>
</module>
<module name="MethodName"> <module name="MethodName">
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/> <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
<message key="name.invalidPattern" <message key="name.invalidPattern"

View File

@ -22,13 +22,16 @@
*/ */
package com.iluwatar.dao; package com.iluwatar.dao;
/**
* Customer Schema SQL Class
*/
public final class CustomerSchemaSql { public final class CustomerSchemaSql {
private 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))"; + "LNAME VARCHAR(100))";
public static final String DELETE_SCHEMA_SQL = "DROP TABLE CUSTOMERS"; public static final String DELETE_SCHEMA_SQL = "DROP TABLE CUSTOMERS";
} }

View File

@ -29,6 +29,9 @@ import static org.junit.Assert.assertNotEquals;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
/**
* Tests {@link Customer}.
*/
public class CustomerTest { public class CustomerTest {
private Customer customer; private Customer customer;

View File

@ -21,6 +21,9 @@ package com.iluwatar.datamapper;
import java.io.Serializable; import java.io.Serializable;
/**
* Class defining Student
*/
public final class Student implements Serializable { public final class Student implements Serializable {
private static final long serialVersionUID = 1L; 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 * Use this constructor to create a Student with all details
* *
* @param studentId as unique student id * @param studentId as unique student id
* @param name as student name * @param name as student name
* @param grade as respective grade of student * @param grade as respective grade of student
@ -46,7 +49,7 @@ public final class Student implements Serializable {
} }
/** /**
* *
* @return the student id * @return the student id
*/ */
public int getStudentId() { public int getStudentId() {
@ -54,7 +57,7 @@ public final class Student implements Serializable {
} }
/** /**
* *
* @param studentId as unique student id * @param studentId as unique student id
*/ */
public void setStudentId(final int studentId) { public void setStudentId(final int studentId) {
@ -62,7 +65,7 @@ public final class Student implements Serializable {
} }
/** /**
* *
* @return name of student * @return name of student
*/ */
public String getName() { public String getName() {
@ -70,7 +73,7 @@ public final class Student implements Serializable {
} }
/** /**
* *
* @param name as 'name' of student * @param name as 'name' of student
*/ */
public void setName(final String name) { public void setName(final String name) {
@ -78,7 +81,7 @@ public final class Student implements Serializable {
} }
/** /**
* *
* @return grade of student * @return grade of student
*/ */
public char getGrade() { public char getGrade() {
@ -86,7 +89,7 @@ public final class Student implements Serializable {
} }
/** /**
* *
* @param grade as 'grade of student' * @param grade as 'grade of student'
*/ */
public void setGrade(final char grade) { public void setGrade(final char grade) {
@ -94,7 +97,7 @@ public final class Student implements Serializable {
} }
/** /**
* *
*/ */
@Override @Override
public boolean equals(final Object inputObject) { public boolean equals(final Object inputObject) {
@ -120,7 +123,7 @@ public final class Student implements Serializable {
} }
/** /**
* *
*/ */
@Override @Override
public int hashCode() { public int hashCode() {
@ -130,7 +133,7 @@ public final class Student implements Serializable {
} }
/** /**
* *
*/ */
@Override @Override
public String toString() { public String toString() {

View File

@ -20,6 +20,9 @@ package com.iluwatar.datamapper;
import java.util.Optional; import java.util.Optional;
/**
* Interface lists out the possible behaviour for all possible student mappers
*/
public interface StudentDataMapper { public interface StudentDataMapper {
Optional<Student> find(int studentId); Optional<Student> find(int studentId);

View File

@ -22,6 +22,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
/**
* Implementation of Actions on Students Data
*/
public final class StudentDataMapperImpl implements StudentDataMapper { public final class StudentDataMapperImpl implements StudentDataMapper {
/* Note: Normally this would be in the form of an actual database */ /* Note: Normally this would be in the form of an actual database */

View File

@ -18,17 +18,21 @@
*/ */
package com.iluwatar.datamapper; 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.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* Tests {@link Student}.
*/
public final class StudentTest { public final class StudentTest {
@Test @Test
/** /**
* This API tests the equality behaviour of Student object * This API tests the equality behaviour of Student object
* Object Equality should work as per logic defined in equals method * Object Equality should work as per logic defined in equals method
* *
* @throws Exception if any execution error during test * @throws Exception if any execution error during test
*/ */
public void testEquality() throws Exception { public void testEquality() throws Exception {

View File

@ -22,6 +22,12 @@
*/ */
package com.iluwatar.delegation.simple; 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 { public class PrinterController implements Printer {
private final Printer printer; private final Printer printer;

View File

@ -23,7 +23,9 @@
package com.iluwatar.delegation.simple; package com.iluwatar.delegation.simple;
import org.junit.Test; import org.junit.Test;
/**
* Application Test Entry
*/
public class AppTest { public class AppTest {
@Test @Test

View File

@ -22,22 +22,24 @@
*/ */
package com.iluwatar.delegation.simple; package com.iluwatar.delegation.simple;
import static org.junit.Assert.assertEquals;
import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase; import ch.qos.logback.core.AppenderBase;
import com.iluwatar.delegation.simple.printers.CanonPrinter; import com.iluwatar.delegation.simple.printers.CanonPrinter;
import com.iluwatar.delegation.simple.printers.EpsonPrinter; import com.iluwatar.delegation.simple.printers.EpsonPrinter;
import com.iluwatar.delegation.simple.printers.HpPrinter; import com.iluwatar.delegation.simple.printers.HpPrinter;
import java.util.LinkedList;
import java.util.List;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.LinkedList; /**
import java.util.List; * Test for Delegation Pattern
*/
import static org.junit.Assert.assertEquals;
public class DelegateTest { public class DelegateTest {
private InMemoryAppender appender; private InMemoryAppender appender;
@ -78,6 +80,9 @@ public class DelegateTest {
assertEquals("Epson Printer : Test Message Printed", appender.getLastMessage()); assertEquals("Epson Printer : Test Message Printed", appender.getLastMessage());
} }
/**
* Logging Appender
*/
private class InMemoryAppender extends AppenderBase<ILoggingEvent> { private class InMemoryAppender extends AppenderBase<ILoggingEvent> {
private List<ILoggingEvent> log = new LinkedList<>(); private List<ILoggingEvent> log = new LinkedList<>();

View File

@ -30,6 +30,10 @@ import org.slf4j.LoggerFactory;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
/**
* InMemory Log Appender Util.
*/
public class InMemoryAppender extends AppenderBase<ILoggingEvent> { public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
private List<ILoggingEvent> log = new LinkedList<>(); private List<ILoggingEvent> log = new LinkedList<>();

View File

@ -22,13 +22,14 @@
*/ */
package com.iluwatar.doubledispatch; package com.iluwatar.doubledispatch;
import java.util.Objects;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import java.util.Objects;
/** /**
* Date: 12/10/15 - 8:37 PM * Date: 12/10/15 - 8:37 PM
* * Test for Collision
* @param <O> Type of GameObject
* @author Jeroen Meulemeester * @author Jeroen Meulemeester
*/ */
public abstract class CollisionTest<O extends GameObject> { public abstract class CollisionTest<O extends GameObject> {

View File

@ -22,22 +22,22 @@
*/ */
package com.iluwatar.event.aggregator; 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.Matchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions; 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 * Date: 12/12/15 - 10:58 PM
* * Tests for Event Emitter
* @param <E> Type of Event Emitter
* @author Jeroen Meulemeester * @author Jeroen Meulemeester
*/ */
public abstract class EventEmitterTest<E extends EventEmitter> { 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 // The observers should not have received any additional events after the week
verifyNoMoreInteractions(observers); verifyNoMoreInteractions(observers);
} }
/** /**
* Go over every day of the month, and check if the event is emitted on the given day. Use an * 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 * event emitter without a default observer

View File

@ -16,6 +16,9 @@
*/ */
package com.iluwatar.event.asynchronous; package com.iluwatar.event.asynchronous;
/**
* Custom Exception Class for Non Existent Event
*/
public class EventDoesNotExistException extends Exception { public class EventDoesNotExistException extends Exception {
private static final long serialVersionUID = -3398463738273811509L; private static final long serialVersionUID = -3398463738273811509L;

View File

@ -16,6 +16,10 @@
*/ */
package com.iluwatar.event.asynchronous; package com.iluwatar.event.asynchronous;
/**
* Events that fulfill the start stop and list out current status behaviour
* follow this interface
*/
public interface IEvent { public interface IEvent {
void start(); void start();

View File

@ -16,6 +16,9 @@
*/ */
package com.iluwatar.event.asynchronous; package com.iluwatar.event.asynchronous;
/**
* Type of Exception raised when the Operation being invoked is Invalid
*/
public class InvalidOperationException extends Exception { public class InvalidOperationException extends Exception {
private static final long serialVersionUID = -6191545255213410803L; private static final long serialVersionUID = -6191545255213410803L;

View File

@ -16,6 +16,9 @@
*/ */
package com.iluwatar.event.asynchronous; package com.iluwatar.event.asynchronous;
/**
* Type of Exception raised when the Operation being invoked is Long Running
*/
public class LongRunningEventException extends Exception { public class LongRunningEventException extends Exception {
private static final long serialVersionUID = -483423544320148809L; private static final long serialVersionUID = -483423544320148809L;

View File

@ -16,6 +16,9 @@
*/ */
package com.iluwatar.event.asynchronous; package com.iluwatar.event.asynchronous;
/**
* Type of Exception raised when the max number of allowed events is exceeded
*/
public class MaxNumOfEventsAllowedException extends Exception { public class MaxNumOfEventsAllowedException extends Exception {
private static final long serialVersionUID = -8430876973516292695L; private static final long serialVersionUID = -8430876973516292695L;

View File

@ -16,6 +16,9 @@
*/ */
package com.iluwatar.event.asynchronous; package com.iluwatar.event.asynchronous;
/**
* Interface with listener behaviour related to Thread Completion.
*/
public interface ThreadCompleteListener { public interface ThreadCompleteListener {
void completedEventHandler(final int eventId); void completedEventHandler(final int eventId);
} }

View File

@ -25,6 +25,7 @@ package com.iluwatar.eda.framework;
/** /**
* This interface can be implemented to handle different types of messages. * This interface can be implemented to handle different types of messages.
* Every handler is responsible for a single of type message * 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> { 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. * @param event the {@link Event} object to be handled.
*/ */
void onEvent(E event); void onEvent(E event);
} }

View File

@ -22,6 +22,9 @@
*/ */
package com.iluwatar.factorykit; package com.iluwatar.factorykit;
/**
* Class representing Axe
*/
public class Axe implements Weapon { public class Axe implements Weapon {
@Override @Override
public String toString() { public String toString() {

View File

@ -22,6 +22,9 @@
*/ */
package com.iluwatar.factorykit; package com.iluwatar.factorykit;
/**
* Class representing Bows
*/
public class Bow implements Weapon { public class Bow implements Weapon {
@Override @Override
public String toString() { public String toString() {

View File

@ -21,7 +21,9 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.iluwatar.factorykit; package com.iluwatar.factorykit;
/**
* Class representing Spear
*/
public class Spear implements Weapon { public class Spear implements Weapon {
@Override @Override
public String toString() { public String toString() {

View File

@ -21,7 +21,9 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.iluwatar.factorykit; package com.iluwatar.factorykit;
/**
* Class representing Swords
*/
public class Sword implements Weapon { public class Sword implements Weapon {
@Override @Override
public String toString() { public String toString() {

View File

@ -25,6 +25,9 @@ package com.iluwatar.factorykit.app;
import com.iluwatar.factorykit.App; import com.iluwatar.factorykit.App;
import org.junit.Test; import org.junit.Test;
/**
* Application Test Entrypoint
*/
public class AppTest { public class AppTest {
@Test @Test

View File

@ -1,4 +1,4 @@
/** /**
* The MIT License * The MIT License
* Copyright (c) 2014-2016 Ilkka Seppälä * Copyright (c) 2014-2016 Ilkka Seppälä
* *
@ -22,12 +22,19 @@
*/ */
package com.iluwatar.factorykit.factorykit; package com.iluwatar.factorykit.factorykit;
import com.iluwatar.factorykit.*;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue; 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 { public class FactoryKitTest {
private WeaponFactory factory; private WeaponFactory factory;

View File

@ -23,16 +23,18 @@
package com.iluwatar.featuretoggle.pattern.propertiesversion; 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.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; 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 { public class PropertiesFeatureToggleVersionTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@ -66,4 +68,4 @@ public class PropertiesFeatureToggleVersionTest {
final String welcomeMessage = service.getWelcomeMessage(new User("Jamie No Code")); final String welcomeMessage = service.getWelcomeMessage(new User("Jamie No Code"));
assertEquals("Welcome to the application.", welcomeMessage); assertEquals("Welcome to the application.", welcomeMessage);
} }
} }

View File

@ -22,15 +22,18 @@
*/ */
package com.iluwatar.featuretoggle.pattern.tieredversion; 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.pattern.Service;
import com.iluwatar.featuretoggle.user.User; import com.iluwatar.featuretoggle.user.User;
import com.iluwatar.featuretoggle.user.UserGroup; import com.iluwatar.featuretoggle.user.UserGroup;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals; /**
import static org.junit.Assert.assertTrue; * Test Tiered Feature Toggle
*/
public class TieredFeatureToggleVersionTest { public class TieredFeatureToggleVersionTest {
final User paidUser = new User("Jamie Coder"); final User paidUser = new User("Jamie Coder");
@ -61,4 +64,4 @@ public class TieredFeatureToggleVersionTest {
public void testIsEnhancedAlwaysTrueAsTiered() throws Exception { public void testIsEnhancedAlwaysTrueAsTiered() throws Exception {
assertTrue(service.isEnhanced()); assertTrue(service.isEnhanced());
} }
} }

View File

@ -22,11 +22,14 @@
*/ */
package com.iluwatar.featuretoggle.user; package com.iluwatar.featuretoggle.user;
import org.junit.Test;
import static junit.framework.TestCase.assertFalse; import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* Test User Group specific feature
*/
public class UserGroupTest { public class UserGroupTest {
@Test @Test
@ -56,4 +59,4 @@ public class UserGroupTest {
UserGroup.addUserToPaidGroup(user); UserGroup.addUserToPaidGroup(user);
UserGroup.addUserToFreeGroup(user); UserGroup.addUserToFreeGroup(user);
} }
} }

View File

@ -27,6 +27,7 @@ import java.util.Iterator;
/** /**
* This class is used to realize LazyFluentIterables. It decorates a given iterator. Does not * This class is used to realize LazyFluentIterables. It decorates a given iterator. Does not
* support consecutive hasNext() calls. * support consecutive hasNext() calls.
* @param <E> Iterable Collection of Elements of Type E
*/ */
public abstract class DecoratingIterator<E> implements Iterator<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. * Precomputes and saves the next element of the Iterable. null is considered as end of data.
* *
* @return true if a next element is available * @return true if a next element is available
*/ */
@Override @Override
@ -54,7 +55,7 @@ public abstract class DecoratingIterator<E> implements Iterator<E> {
/** /**
* Returns the next element of the Iterable. * Returns the next element of the Iterable.
* *
* @return the next element of the Iterable, or null if not present. * @return the next element of the Iterable, or null if not present.
*/ */
@Override @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 * 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. * iteration process. null is considered as end of data.
* *
* @return the next element of the Iterable. * @return the next element of the Iterable.
*/ */
public abstract E computeNext(); public abstract E computeNext();

View File

@ -23,7 +23,9 @@
package com.iluwatar.fluentinterface.app; package com.iluwatar.fluentinterface.app;
import org.junit.Test; import org.junit.Test;
/**
* Application Test Entry
*/
public class AppTest { public class AppTest {
@Test @Test

View File

@ -30,6 +30,9 @@ import org.slf4j.LoggerFactory;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
/**
* InMemory Log Appender Util.
*/
public class InMemoryAppender extends AppenderBase<ILoggingEvent> { public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
private List<ILoggingEvent> log = new LinkedList<>(); private List<ILoggingEvent> log = new LinkedList<>();

View File

@ -28,7 +28,12 @@ import org.slf4j.LoggerFactory;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Queue; 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 { public class GuardedQueue {
private static final Logger LOGGER = LoggerFactory.getLogger(GuardedQueue.class); private static final Logger LOGGER = LoggerFactory.getLogger(GuardedQueue.class);
private final Queue<Integer> sourceList; private final Queue<Integer> sourceList;

View File

@ -29,6 +29,9 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/**
* Test for Guarded Queue
*/
public class GuardedQueueTest { public class GuardedQueueTest {
private volatile Integer value; private volatile Integer value;
@ -55,4 +58,4 @@ public class GuardedQueueTest {
} }
} }

View File

@ -23,12 +23,15 @@
package com.iluwatar.hexagonal.domain; package com.iluwatar.hexagonal.domain;
/** /**
* *
* Represents lottery ticket check result. * Represents lottery ticket check result.
* *
*/ */
public class LotteryTicketCheckResult { public class LotteryTicketCheckResult {
/**
* Enumeration of Type of Outcomes of a Lottery
*/
public enum CheckResult { WIN_PRIZE, NO_PRIZE, TICKET_NOT_SUBMITTED } public enum CheckResult { WIN_PRIZE, NO_PRIZE, TICKET_NOT_SUBMITTED }
private final CheckResult checkResult; private final CheckResult checkResult;
@ -41,7 +44,7 @@ public class LotteryTicketCheckResult {
checkResult = result; checkResult = result;
prizeAmount = 0; prizeAmount = 0;
} }
/** /**
* Constructor. * Constructor.
*/ */
@ -56,7 +59,7 @@ public class LotteryTicketCheckResult {
public CheckResult getResult() { public CheckResult getResult() {
return checkResult; return checkResult;
} }
/** /**
* @return prize amount * @return prize amount
*/ */

View File

@ -30,6 +30,9 @@ import java.util.HashSet;
import org.junit.Test; import org.junit.Test;
/**
* Test Lottery Tickets for equality
*/
public class LotteryTicketTest { public class LotteryTicketTest {
@Test @Test

View File

@ -22,18 +22,19 @@
*/ */
package com.iluwatar.interpreter; 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.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/** /**
* Date: 12/14/15 - 11:48 AM * Date: 12/14/15 - 11:48 AM
* *
* Test Case for Expressions
* @param <E> Type of Expression
* @author Jeroen Meulemeester * @author Jeroen Meulemeester
*/ */
public abstract class ExpressionTest<E extends Expression> { public abstract class ExpressionTest<E extends Expression> {

View File

@ -22,20 +22,19 @@
*/ */
package com.iluwatar.model.view.controller; 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.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase; import ch.qos.logback.core.AppenderBase;
import java.util.LinkedList;
import java.util.List;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.LoggerFactory; 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 * Date: 12/20/15 - 2:04 PM
* *
@ -70,6 +69,9 @@ public class GiantViewTest {
assertEquals(1, appender.getLogSize()); assertEquals(1, appender.getLogSize());
} }
/**
* Logging Appender Implementation
*/
public class InMemoryAppender extends AppenderBase<ILoggingEvent> { public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
private List<ILoggingEvent> log = new LinkedList<>(); private List<ILoggingEvent> log = new LinkedList<>();

View File

@ -22,6 +22,9 @@
*/ */
package com.iluwatar.monad; package com.iluwatar.monad;
/**
* Enumeration of Types of Sex
*/
public enum Sex { public enum Sex {
MALE, FEMALE MALE, FEMALE
} }

View File

@ -22,6 +22,9 @@
*/ */
package com.iluwatar.monad; package com.iluwatar.monad;
/**
* User Definition
*/
public class User { public class User {
private String name; private String name;

View File

@ -24,6 +24,9 @@ package com.iluwatar.monad;
import org.junit.Test; import org.junit.Test;
/**
* Application Test
*/
public class AppTest { public class AppTest {
@Test @Test

View File

@ -30,6 +30,9 @@ import org.junit.rules.ExpectedException;
import java.util.Objects; import java.util.Objects;
/**
* Test for Monad Pattern
*/
public class MonadTest { public class MonadTest {
@Rule @Rule

View File

@ -24,6 +24,9 @@ package com.iluwatar.monostate;
import org.junit.Test; import org.junit.Test;
/**
* Application Test Entry
*/
public class AppTest { public class AppTest {
@Test @Test

View File

@ -35,47 +35,50 @@ import org.junit.rules.ExpectedException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/**
* Test for the mute-idiom pattern
*/
public class MuteTest { public class MuteTest {
private static final Logger LOGGER = LoggerFactory.getLogger(MuteTest.class); private static final Logger LOGGER = LoggerFactory.getLogger(MuteTest.class);
private static final String MESSAGE = "should not occur"; private static final String MESSAGE = "should not occur";
@Rule public ExpectedException exception = ExpectedException.none(); @Rule public ExpectedException exception = ExpectedException.none();
@Test @Test
public void muteShouldRunTheCheckedRunnableAndNotThrowAnyExceptionIfCheckedRunnableDoesNotThrowAnyException() { public void muteShouldRunTheCheckedRunnableAndNotThrowAnyExceptionIfCheckedRunnableDoesNotThrowAnyException() {
Mute.mute(() -> methodNotThrowingAnyException()); Mute.mute(() -> methodNotThrowingAnyException());
} }
@Test @Test
public void muteShouldRethrowUnexpectedExceptionAsAssertionError() throws Exception { public void muteShouldRethrowUnexpectedExceptionAsAssertionError() throws Exception {
exception.expect(AssertionError.class); exception.expect(AssertionError.class);
exception.expectMessage(MESSAGE); exception.expectMessage(MESSAGE);
Mute.mute(() -> methodThrowingException()); Mute.mute(() -> methodThrowingException());
} }
@Test @Test
public void loggedMuteShouldRunTheCheckedRunnableAndNotThrowAnyExceptionIfCheckedRunnableDoesNotThrowAnyException() { public void loggedMuteShouldRunTheCheckedRunnableAndNotThrowAnyExceptionIfCheckedRunnableDoesNotThrowAnyException() {
Mute.loggedMute(() -> methodNotThrowingAnyException()); Mute.loggedMute(() -> methodNotThrowingAnyException());
} }
@Test @Test
public void loggedMuteShouldLogExceptionTraceBeforeSwallowingIt() throws IOException { public void loggedMuteShouldLogExceptionTraceBeforeSwallowingIt() throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream(); ByteArrayOutputStream stream = new ByteArrayOutputStream();
System.setErr(new PrintStream(stream)); System.setErr(new PrintStream(stream));
Mute.loggedMute(() -> methodThrowingException()); Mute.loggedMute(() -> methodThrowingException());
assertTrue(new String(stream.toByteArray()).contains(MESSAGE)); assertTrue(new String(stream.toByteArray()).contains(MESSAGE));
} }
private void methodNotThrowingAnyException() { private void methodNotThrowingAnyException() {
LOGGER.info("Executed successfully"); LOGGER.info("Executed successfully");
} }
private void methodThrowingException() throws Exception { private void methodThrowingException() throws Exception {
throw new Exception(MESSAGE); throw new Exception(MESSAGE);
} }

View File

@ -25,10 +25,13 @@ package com.iluwatar.mutex;
import org.junit.Test; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
/**
* Application Test Entrypoint
*/
public class AppTest{ public class AppTest{
@Test @Test
public void test() throws IOException { public void test() throws IOException {
String[] args = {}; String[] args = {};
App.main(args); App.main(args);
} }
} }

View File

@ -4,9 +4,9 @@
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * 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 * "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at * copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software distributed under the License * 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 * 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 * 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.NatureOfService;
import org.apache.isis.applib.annotation.SemanticsOf; import org.apache.isis.applib.annotation.SemanticsOf;
/**
* HomePage Domain Service
* @see HomePageViewModel linked view to HomePage
*/
@DomainService(nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY) @DomainService(nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY)
public class HomePageService { public class HomePageService {

View File

@ -4,9 +4,9 @@
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * 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 * "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at * copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software distributed under the License * 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 * 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 * 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.SimpleObject;
import domainapp.dom.modules.simple.SimpleObjects; 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 @ViewModel
public class HomePageViewModel { public class HomePageViewModel {

View File

@ -4,9 +4,9 @@
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * 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 * "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at * copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software distributed under the License * 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 * 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 * 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.services.i18n.TranslatableString;
import org.apache.isis.applib.util.ObjectContracts; import org.apache.isis.applib.util.ObjectContracts;
/**
* Definition of a Simple Object
*/
@javax.jdo.annotations.PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "simple", @javax.jdo.annotations.PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "simple",
table = "SimpleObject") table = "SimpleObject")
@javax.jdo.annotations.DatastoreIdentity( @javax.jdo.annotations.DatastoreIdentity(
@ -53,7 +56,7 @@ public class SimpleObject implements Comparable<SimpleObject> {
// region > name (property) // region > name (property)
private String name; private String name;
// region > identificatiom // region > identificatiom
public TranslatableString title() { public TranslatableString title() {
return TranslatableString.tr("Object: {name}", "name", getName()); return TranslatableString.tr("Object: {name}", "name", getName());
@ -74,6 +77,9 @@ public class SimpleObject implements Comparable<SimpleObject> {
// region > updateName (action) // region > updateName (action)
/**
* Event used to update the Name in the Domain
*/
public static class UpdateNameDomainEvent extends ActionDomainEvent<SimpleObject> { public static class UpdateNameDomainEvent extends ActionDomainEvent<SimpleObject> {
public UpdateNameDomainEvent(final SimpleObject source, final Identifier identifier, public UpdateNameDomainEvent(final SimpleObject source, final Identifier identifier,
final Object... arguments) { final Object... arguments) {

View File

@ -4,9 +4,9 @@
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * 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 * "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at * copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software distributed under the License * 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 * 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 * 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.eventbus.ActionDomainEvent;
import org.apache.isis.applib.services.i18n.TranslatableString; import org.apache.isis.applib.services.i18n.TranslatableString;
/**
* Domain Service for Simple Objects
*/
@DomainService(repositoryFor = SimpleObject.class) @DomainService(repositoryFor = SimpleObject.class)
@DomainServiceLayout(menuOrder = "10") @DomainServiceLayout(menuOrder = "10")
public class SimpleObjects { public class SimpleObjects {
@ -69,6 +72,9 @@ public class SimpleObjects {
// endregion // endregion
/**
* Create Domain Event on SimpleObjects
*/
// region > create (action) // region > create (action)
public static class CreateDomainEvent extends ActionDomainEvent<SimpleObjects> { public static class CreateDomainEvent extends ActionDomainEvent<SimpleObjects> {
public CreateDomainEvent(final SimpleObjects source, final Identifier identifier, public CreateDomainEvent(final SimpleObjects source, final Identifier identifier,

View File

@ -14,11 +14,14 @@
*/ */
package domainapp.dom.modules.simple; package domainapp.dom.modules.simple;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat; /**
* Test for SimpleObject
*/
public class SimpleObjectTest { public class SimpleObjectTest {
SimpleObject simpleObject; SimpleObject simpleObject;
@ -28,6 +31,9 @@ public class SimpleObjectTest {
simpleObject = new SimpleObject(); simpleObject = new SimpleObject();
} }
/**
* Test for Names for SimpleObjects
*/
public static class Name extends SimpleObjectTest { public static class Name extends SimpleObjectTest {
@Test @Test

View File

@ -14,10 +14,13 @@
*/ */
package domainapp.dom.modules.simple; package domainapp.dom.modules.simple;
import java.util.List; import static org.assertj.core.api.Assertions.assertThat;
import com.google.common.collect.Lists; 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.Expectations;
import org.jmock.Sequence; import org.jmock.Sequence;
import org.jmock.auto.Mock; import org.jmock.auto.Mock;
@ -25,12 +28,9 @@ import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.apache.isis.applib.DomainObjectContainer; /**
import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2; * Test for SimpleObjects
import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode; */
import static org.assertj.core.api.Assertions.assertThat;
public class SimpleObjectsTest { public class SimpleObjectsTest {
@Rule @Rule
@ -47,6 +47,9 @@ public class SimpleObjectsTest {
simpleObjects.container = mockContainer; simpleObjects.container = mockContainer;
} }
/**
* Test Creation of Simple Objects
*/
public static class Create extends SimpleObjectsTest { public static class Create extends SimpleObjectsTest {
@Test @Test
@ -77,6 +80,9 @@ public class SimpleObjectsTest {
} }
/**
* Test Listing of Simple Objects
*/
public static class ListAll extends SimpleObjectsTest { public static class ListAll extends SimpleObjectsTest {
@Test @Test

View File

@ -4,9 +4,9 @@
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * 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 * "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at * copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software distributed under the License * 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 * 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 * 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.SimpleObject;
import domainapp.dom.modules.simple.SimpleObjects; import domainapp.dom.modules.simple.SimpleObjects;
/**
* Fixture to create a simple object
*/
public class SimpleObjectCreate extends FixtureScript { public class SimpleObjectCreate extends FixtureScript {
// endregion // endregion
@ -45,7 +48,7 @@ public class SimpleObjectCreate extends FixtureScript {
this.name = name; this.name = name;
return this; return this;
} }
/** /**
* The created simple object (output). * The created simple object (output).
*/ */
@ -65,5 +68,5 @@ public class SimpleObjectCreate extends FixtureScript {
// also make available to UI // also make available to UI
ec.addResult(this, simpleObject); ec.addResult(this, simpleObject);
} }
} }

View File

@ -4,9 +4,9 @@
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * 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 * "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at * copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software distributed under the License * 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 * 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 * 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.fixturescripts.FixtureScript;
import org.apache.isis.applib.services.jdosupport.IsisJdoSupport; import org.apache.isis.applib.services.jdosupport.IsisJdoSupport;
/**
* TearDown/Cleanup for SimpleObjects
*/
public class SimpleObjectsTearDown extends FixtureScript { public class SimpleObjectsTearDown extends FixtureScript {
@javax.inject.Inject @javax.inject.Inject
@ -27,5 +30,5 @@ public class SimpleObjectsTearDown extends FixtureScript {
protected void execute(ExecutionContext executionContext) { protected void execute(ExecutionContext executionContext) {
isisJdoSupport.executeUpdate("delete from \"simple\".\"SimpleObject\""); isisJdoSupport.executeUpdate("delete from \"simple\".\"SimpleObject\"");
} }
} }

View File

@ -4,9 +4,9 @@
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * 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 * "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at * copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software distributed under the License * 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 * 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 * 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.SimpleObjectCreate;
import domainapp.fixture.modules.simple.SimpleObjectsTearDown; import domainapp.fixture.modules.simple.SimpleObjectsTearDown;
/**
* Create a bunch of simple Objects
*/
public class RecreateSimpleObjects extends FixtureScript { public class RecreateSimpleObjects extends FixtureScript {
public final List<String> names = Collections.unmodifiableList(Arrays.asList("Foo", "Bar", "Baz", public final List<String> names = Collections.unmodifiableList(Arrays.asList("Foo", "Bar", "Baz",
@ -43,7 +47,7 @@ public class RecreateSimpleObjects extends FixtureScript {
public RecreateSimpleObjects() { public RecreateSimpleObjects() {
withDiscoverability(Discoverability.DISCOVERABLE); withDiscoverability(Discoverability.DISCOVERABLE);
} }
/** /**
* The number of objects to create, up to 10; optional, defaults to 3. * 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; this.number = number;
return this; return this;
} }
/** /**
* The simpleobjects created by this fixture (output). * The simpleobjects created by this fixture (output).
*/ */

View File

@ -4,9 +4,9 @@
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the * 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 * "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at * copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software distributed under the License * 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 * 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 * 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.DataNucleusPersistenceMechanismInstaller;
import org.apache.isis.objectstore.jdo.datanucleus.IsisConfigurationForJdoIntegTests; import org.apache.isis.objectstore.jdo.datanucleus.IsisConfigurationForJdoIntegTests;
/**
* Initializer for the Simple App
*/
public final class SimpleAppSystemInitializer { public final class SimpleAppSystemInitializer {
private SimpleAppSystemInitializer() { private SimpleAppSystemInitializer() {

View File

@ -21,6 +21,9 @@ import cucumber.api.java.After;
import cucumber.api.java.Before; import cucumber.api.java.Before;
import domainapp.integtests.bootstrap.SimpleAppSystemInitializer; import domainapp.integtests.bootstrap.SimpleAppSystemInitializer;
/**
* BootStrapping IntegrationTesting Before and After Steps
*/
public class BootstrappingGlue extends CukeGlueAbstract { public class BootstrappingGlue extends CukeGlueAbstract {
@Before(value = {"@integration"}, order = 100) @Before(value = {"@integration"}, order = 100)

View File

@ -19,6 +19,9 @@ import org.apache.isis.core.specsupport.specs.CukeGlueAbstract;
import cucumber.api.java.Before; import cucumber.api.java.Before;
import domainapp.fixture.scenarios.RecreateSimpleObjects; import domainapp.fixture.scenarios.RecreateSimpleObjects;
/**
* Test Execution to append a fixture of SimpleObjects
*/
public class CatalogOfFixturesGlue extends CukeGlueAbstract { public class CatalogOfFixturesGlue extends CukeGlueAbstract {
@Before(value = {"@integration", "@SimpleObjectsFixture"}, order = 20000) @Before(value = {"@integration", "@SimpleObjectsFixture"}, order = 20000)

View File

@ -14,18 +14,20 @@
*/ */
package domainapp.integtests.specglue.modules.simple; package domainapp.integtests.specglue.modules.simple;
import java.util.List; import static org.hamcrest.CoreMatchers.is;
import java.util.UUID; import static org.junit.Assert.assertThat;
import org.apache.isis.core.specsupport.specs.CukeGlueAbstract;
import cucumber.api.java.en.Given; import cucumber.api.java.en.Given;
import cucumber.api.java.en.When; import cucumber.api.java.en.When;
import domainapp.dom.modules.simple.SimpleObject; import domainapp.dom.modules.simple.SimpleObject;
import domainapp.dom.modules.simple.SimpleObjects; import domainapp.dom.modules.simple.SimpleObjects;
import static org.hamcrest.CoreMatchers.is; import java.util.List;
import static org.junit.Assert.assertThat; import java.util.UUID;
import org.apache.isis.core.specsupport.specs.CukeGlueAbstract;
/**
* Test Simple Object Operations
*/
public class SimpleObjectGlue extends CukeGlueAbstract { public class SimpleObjectGlue extends CukeGlueAbstract {
@Given("^there are.* (\\d+) simple objects$") @Given("^there are.* (\\d+) simple objects$")

View File

@ -25,6 +25,9 @@ import org.apache.isis.core.integtestsupport.scenarios.ScenarioExecutionForInteg
import domainapp.integtests.bootstrap.SimpleAppSystemInitializer; import domainapp.integtests.bootstrap.SimpleAppSystemInitializer;
/**
* SimpleApp Integration Tests will implement this Abstract Class.
*/
public abstract class SimpleAppIntegTest extends IntegrationTestAbstract { public abstract class SimpleAppIntegTest extends IntegrationTestAbstract {
@BeforeClass @BeforeClass
@ -35,5 +38,4 @@ public abstract class SimpleAppIntegTest extends IntegrationTestAbstract {
// instantiating will install onto ThreadLocal // instantiating will install onto ThreadLocal
new ScenarioExecutionForIntegration(); new ScenarioExecutionForIntegration();
} }
} }

View File

@ -18,21 +18,22 @@
*/ */
package domainapp.integtests.tests.modules.simple; package domainapp.integtests.tests.modules.simple;
import javax.inject.Inject; import static org.assertj.core.api.Assertions.assertThat;
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 domainapp.dom.modules.simple.SimpleObject; import domainapp.dom.modules.simple.SimpleObject;
import domainapp.fixture.scenarios.RecreateSimpleObjects; import domainapp.fixture.scenarios.RecreateSimpleObjects;
import domainapp.integtests.tests.SimpleAppIntegTest; 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 { public class SimpleObjectIntegTest extends SimpleAppIntegTest {
@Inject @Inject
@ -54,6 +55,9 @@ public class SimpleObjectIntegTest extends SimpleAppIntegTest {
simpleObjectWrapped = wrap(simpleObjectPojo); simpleObjectWrapped = wrap(simpleObjectPojo);
} }
/**
* Test Object Name accessibility
*/
public static class Name extends SimpleObjectIntegTest { public static class Name extends SimpleObjectIntegTest {
@Test @Test
@ -75,6 +79,9 @@ public class SimpleObjectIntegTest extends SimpleAppIntegTest {
} }
} }
/**
* Test Validation of SimpleObject Names
*/
public static class UpdateName extends SimpleObjectIntegTest { public static class UpdateName extends SimpleObjectIntegTest {
@Test @Test
@ -99,6 +106,9 @@ public class SimpleObjectIntegTest extends SimpleAppIntegTest {
} }
} }
/**
* Test ContainerTitle generation based on SimpleObject Name
*/
public static class Title extends SimpleObjectIntegTest { public static class Title extends SimpleObjectIntegTest {
@Inject @Inject
@ -117,4 +127,4 @@ public class SimpleObjectIntegTest extends SimpleAppIntegTest {
assertThat(title).isEqualTo("Object: " + name); assertThat(title).isEqualTo("Object: " + name);
} }
} }
} }

View File

@ -18,28 +18,27 @@
*/ */
package domainapp.integtests.tests.modules.simple; package domainapp.integtests.tests.modules.simple;
import java.sql.SQLIntegrityConstraintViolationException; import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import javax.inject.Inject;
import com.google.common.base.Throwables; 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.SimpleObject;
import domainapp.dom.modules.simple.SimpleObjects; import domainapp.dom.modules.simple.SimpleObjects;
import domainapp.fixture.modules.simple.SimpleObjectsTearDown; import domainapp.fixture.modules.simple.SimpleObjectsTearDown;
import domainapp.fixture.scenarios.RecreateSimpleObjects; import domainapp.fixture.scenarios.RecreateSimpleObjects;
import domainapp.integtests.tests.SimpleAppIntegTest; 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 { public class SimpleObjectsIntegTest extends SimpleAppIntegTest {
@Inject @Inject
@ -47,6 +46,9 @@ public class SimpleObjectsIntegTest extends SimpleAppIntegTest {
@Inject @Inject
SimpleObjects simpleObjects; SimpleObjects simpleObjects;
/**
* Test Listing of All Simple Objects
*/
public static class ListAll extends SimpleObjectsIntegTest { public static class ListAll extends SimpleObjectsIntegTest {
@Test @Test
@ -83,6 +85,10 @@ public class SimpleObjectsIntegTest extends SimpleAppIntegTest {
} }
} }
/**
* Test Creation of Simple Objects
*/
public static class Create extends SimpleObjectsIntegTest { public static class Create extends SimpleObjectsIntegTest {
@Test @Test
@ -140,4 +146,4 @@ public class SimpleObjectsIntegTest extends SimpleAppIntegTest {
} }
} }
} }

View File

@ -22,6 +22,9 @@
*/ */
package com.iluwatar.objectmother; package com.iluwatar.objectmother;
/**
* Defines all attributes and behaviour related to the King
*/
public class King implements Royalty { public class King implements Royalty {
boolean isDrunk = false; boolean isDrunk = false;
boolean isHappy = false; boolean isHappy = false;
@ -45,11 +48,11 @@ public class King implements Royalty {
public void makeUnhappy() { public void makeUnhappy() {
isHappy = false; isHappy = false;
} }
public boolean isHappy() { public boolean isHappy() {
return isHappy; return isHappy;
} }
/** /**
* Method to flirt to a queen. * Method to flirt to a queen.
* @param queen Queen which should be flirted. * @param queen Queen which should be flirted.
@ -61,6 +64,6 @@ public class King implements Royalty {
} else { } else {
this.makeHappy(); this.makeHappy();
} }
} }
} }

View File

@ -22,6 +22,9 @@
*/ */
package com.iluwatar.objectmother; package com.iluwatar.objectmother;
/**
* Defines all attributes and behaviour related to the Queen
*/
public class Queen implements Royalty { public class Queen implements Royalty {
private boolean isDrunk = false; private boolean isDrunk = false;
private boolean isHappy = false; private boolean isHappy = false;
@ -46,7 +49,7 @@ public class Queen implements Royalty {
public void makeUnhappy() { public void makeUnhappy() {
isHappy = false; isHappy = false;
} }
public boolean isFlirty() { public boolean isFlirty() {
return isFlirty; return isFlirty;
} }
@ -54,7 +57,7 @@ public class Queen implements Royalty {
public void setFlirtiness(boolean flirtiness) { public void setFlirtiness(boolean flirtiness) {
this.isFlirty = flirtiness; this.isFlirty = flirtiness;
} }
/** /**
* Method which is called when the king is flirting to a queen. * Method which is called when the king is flirting to a queen.
* @param king King who initialized the flirt. * @param king King who initialized the flirt.

View File

@ -22,12 +22,15 @@
*/ */
package com.iluwatar.objectmother; package com.iluwatar.objectmother;
/**
* Interface contracting Royalty Behaviour
*/
public interface Royalty { public interface Royalty {
void makeDrunk(); void makeDrunk();
void makeSober(); void makeSober();
void makeHappy(); void makeHappy();
void makeUnhappy(); void makeUnhappy();
} }

View File

@ -22,8 +22,11 @@
*/ */
package com.iluwatar.objectmother; package com.iluwatar.objectmother;
/**
* Object Mother Pattern generating Royalty Types
*/
public final class RoyaltyObjectMother { public final class RoyaltyObjectMother {
/** /**
* Method to create a sober and unhappy king. The standard paramters are set. * 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. * @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() { public static King createSoberUnhappyKing() {
return new King(); return new King();
} }
/** /**
* Method of the object mother to create a drunk king. * Method of the object mother to create a drunk king.
* @return A drunk {@link com.iluwatar.objectmother.King}. * @return A drunk {@link com.iluwatar.objectmother.King}.
@ -41,7 +44,7 @@ public final class RoyaltyObjectMother {
king.makeDrunk(); king.makeDrunk();
return king; return king;
} }
/** /**
* Method to create a happy king. * Method to create a happy king.
* @return A happy {@link com.iluwatar.objectmother.King}. * @return A happy {@link com.iluwatar.objectmother.King}.
@ -51,7 +54,7 @@ public final class RoyaltyObjectMother {
king.makeHappy(); king.makeHappy();
return king; return king;
} }
/** /**
* Method to create a happy and drunk king. * Method to create a happy and drunk king.
* @return A drunk and happy {@link com.iluwatar.objectmother.King}. * @return A drunk and happy {@link com.iluwatar.objectmother.King}.
@ -62,7 +65,7 @@ public final class RoyaltyObjectMother {
king.makeDrunk(); king.makeDrunk();
return king; return king;
} }
/** /**
* Method to create a flirty queen. * Method to create a flirty queen.
* @return A flirty {@link com.iluwatar.objectmother.Queen}. * @return A flirty {@link com.iluwatar.objectmother.Queen}.
@ -72,7 +75,7 @@ public final class RoyaltyObjectMother {
queen.setFlirtiness(true); queen.setFlirtiness(true);
return queen; return queen;
} }
/** /**
* Method to create a not flirty queen. * Method to create a not flirty queen.
* @return A not flirty {@link com.iluwatar.objectmother.Queen}. * @return A not flirty {@link com.iluwatar.objectmother.Queen}.

View File

@ -33,8 +33,11 @@ import com.iluwatar.objectmother.Queen;
import com.iluwatar.objectmother.Royalty; import com.iluwatar.objectmother.Royalty;
import com.iluwatar.objectmother.RoyaltyObjectMother; import com.iluwatar.objectmother.RoyaltyObjectMother;
/**
* Test Generation of Royalty Types using the object-mother
*/
public class RoyaltyObjectMotherTest { public class RoyaltyObjectMotherTest {
@Test @Test
public void unsuccessfulKingFlirt() { public void unsuccessfulKingFlirt() {
King soberUnhappyKing = RoyaltyObjectMother.createSoberUnhappyKing(); King soberUnhappyKing = RoyaltyObjectMother.createSoberUnhappyKing();
@ -42,7 +45,7 @@ public class RoyaltyObjectMotherTest {
soberUnhappyKing.flirt(flirtyQueen); soberUnhappyKing.flirt(flirtyQueen);
assertFalse(soberUnhappyKing.isHappy()); assertFalse(soberUnhappyKing.isHappy());
} }
@Test @Test
public void queenIsBlockingFlirtCauseDrunkKing() { public void queenIsBlockingFlirtCauseDrunkKing() {
King drunkUnhappyKing = RoyaltyObjectMother.createDrunkKing(); King drunkUnhappyKing = RoyaltyObjectMother.createDrunkKing();
@ -50,7 +53,7 @@ public class RoyaltyObjectMotherTest {
drunkUnhappyKing.flirt(notFlirtyQueen); drunkUnhappyKing.flirt(notFlirtyQueen);
assertFalse(drunkUnhappyKing.isHappy()); assertFalse(drunkUnhappyKing.isHappy());
} }
@Test @Test
public void queenIsBlockingFlirt() { public void queenIsBlockingFlirt() {
King soberHappyKing = RoyaltyObjectMother.createHappyKing(); King soberHappyKing = RoyaltyObjectMother.createHappyKing();
@ -58,7 +61,7 @@ public class RoyaltyObjectMotherTest {
soberHappyKing.flirt(notFlirtyQueen); soberHappyKing.flirt(notFlirtyQueen);
assertFalse(soberHappyKing.isHappy()); assertFalse(soberHappyKing.isHappy());
} }
@Test @Test
public void successfullKingFlirt() { public void successfullKingFlirt() {
King soberHappyKing = RoyaltyObjectMother.createHappyKing(); King soberHappyKing = RoyaltyObjectMother.createHappyKing();
@ -66,7 +69,7 @@ public class RoyaltyObjectMotherTest {
soberHappyKing.flirt(flirtyQueen); soberHappyKing.flirt(flirtyQueen);
assertTrue(soberHappyKing.isHappy()); assertTrue(soberHappyKing.isHappy());
} }
@Test @Test
public void testQueenType() { public void testQueenType() {
Royalty flirtyQueen = RoyaltyObjectMother.createFlirtyQueen(); Royalty flirtyQueen = RoyaltyObjectMother.createFlirtyQueen();
@ -74,7 +77,7 @@ public class RoyaltyObjectMotherTest {
assertEquals(flirtyQueen.getClass(), Queen.class); assertEquals(flirtyQueen.getClass(), Queen.class);
assertEquals(notFlirtyQueen.getClass(), Queen.class); assertEquals(notFlirtyQueen.getClass(), Queen.class);
} }
@Test @Test
public void testKingType() { public void testKingType() {
Royalty drunkKing = RoyaltyObjectMother.createDrunkKing(); Royalty drunkKing = RoyaltyObjectMother.createDrunkKing();

View File

@ -26,8 +26,8 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
/** /**
*
* Generic object pool * Generic object pool
* @param <T> Type T of Object in the Pool
*/ */
public abstract class ObjectPool<T> { public abstract class ObjectPool<T> {

View File

@ -23,8 +23,10 @@
package com.iluwatar.observer.generic; package com.iluwatar.observer.generic;
/** /**
*
* Observer * 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> { public interface Observer<S extends Observable<S, O, A>, O extends Observer<S, O, A>, A> {

View File

@ -22,18 +22,18 @@
*/ */
package com.iluwatar.observer; package com.iluwatar.observer;
import static org.junit.Assert.assertEquals;
import com.iluwatar.observer.utils.InMemoryAppender; import com.iluwatar.observer.utils.InMemoryAppender;
import java.util.function.Supplier;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import java.util.function.Supplier;
import static org.junit.Assert.assertEquals;
/** /**
* Date: 12/27/15 - 11:44 AM * Date: 12/27/15 - 11:44 AM
* * Weather Observer Tests
* @param <O> Type of WeatherObserver
* @author Jeroen Meulemeester * @author Jeroen Meulemeester
*/ */
public abstract class WeatherObserverTest<O extends WeatherObserver> { public abstract class WeatherObserverTest<O extends WeatherObserver> {

View File

@ -22,19 +22,19 @@
*/ */
package com.iluwatar.observer.generic; package com.iluwatar.observer.generic;
import static org.junit.Assert.assertEquals;
import com.iluwatar.observer.WeatherType; import com.iluwatar.observer.WeatherType;
import com.iluwatar.observer.utils.InMemoryAppender; import com.iluwatar.observer.utils.InMemoryAppender;
import java.util.function.Supplier;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import java.util.function.Supplier;
import static org.junit.Assert.assertEquals;
/** /**
* Date: 12/27/15 - 11:44 AM * Date: 12/27/15 - 11:44 AM
* * Test for Observers
* @param <O> Type of Observer
* @author Jeroen Meulemeester * @author Jeroen Meulemeester
*/ */
public abstract class ObserverTest<O extends Observer> { public abstract class ObserverTest<O extends Observer> {

View File

@ -30,6 +30,9 @@ import org.slf4j.LoggerFactory;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
/**
* InMemory Log Appender Util.
*/
public class InMemoryAppender extends AppenderBase<ILoggingEvent> { public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
private List<ILoggingEvent> log = new LinkedList<>(); private List<ILoggingEvent> log = new LinkedList<>();

View File

@ -23,15 +23,17 @@
package com.iluwatar.pageobject; package com.iluwatar.pageobject;
import static org.junit.Assert.assertTrue;
import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.WebClient;
import com.iluwatar.pageobject.pages.AlbumListPage; import com.iluwatar.pageobject.pages.AlbumListPage;
import com.iluwatar.pageobject.pages.AlbumPage; import com.iluwatar.pageobject.pages.AlbumPage;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertTrue; /**
* Test Album Selection and Album Listing
*/
public class AlbumListPageTest { public class AlbumListPageTest {
private AlbumListPage albumListPage = new AlbumListPage(new WebClient()); private AlbumListPage albumListPage = new AlbumListPage(new WebClient());

View File

@ -22,14 +22,17 @@
*/ */
package com.iluwatar.pageobject; package com.iluwatar.pageobject;
import static org.junit.Assert.assertTrue;
import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.WebClient;
import com.iluwatar.pageobject.pages.AlbumListPage; import com.iluwatar.pageobject.pages.AlbumListPage;
import com.iluwatar.pageobject.pages.AlbumPage; import com.iluwatar.pageobject.pages.AlbumPage;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertTrue; /**
* Test Album Page Operations
*/
public class AlbumPageTest { public class AlbumPageTest {
private AlbumPage albumPage = new AlbumPage(new WebClient()); private AlbumPage albumPage = new AlbumPage(new WebClient());

View File

@ -22,14 +22,17 @@
*/ */
package com.iluwatar.pageobject; package com.iluwatar.pageobject;
import static org.junit.Assert.assertTrue;
import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.WebClient;
import com.iluwatar.pageobject.pages.AlbumListPage; import com.iluwatar.pageobject.pages.AlbumListPage;
import com.iluwatar.pageobject.pages.LoginPage; import com.iluwatar.pageobject.pages.LoginPage;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertTrue; /**
* Test Login Page Object
*/
public class LoginPageTest { public class LoginPageTest {
private LoginPage loginPage = new LoginPage(new WebClient()); private LoginPage loginPage = new LoginPage(new WebClient());

View File

@ -63,6 +63,9 @@ public interface Message {
}; };
/**
* Enumeration of Type of Headers
*/
public enum Headers { public enum Headers {
DATE, SENDER DATE, SENDER
} }

View File

@ -30,6 +30,9 @@ import org.slf4j.LoggerFactory;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
/**
* InMemory Log Appender Util.
*/
public class InMemoryAppender extends AppenderBase<ILoggingEvent> { public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
private List<ILoggingEvent> log = new LinkedList<>(); private List<ILoggingEvent> log = new LinkedList<>();

View File

@ -39,6 +39,9 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
/**
* Utility to perform various operations
*/
public class Utility { public class Utility {
private static final Logger LOGGER = LoggerFactory.getLogger(Utility.class); private static final Logger LOGGER = LoggerFactory.getLogger(Utility.class);

View File

@ -30,6 +30,9 @@ import java.util.Map;
*/ */
public class Character implements Prototype { public class Character implements Prototype {
/**
* Enumeration of Character types
*/
public enum Type { public enum Type {
WARRIOR, MAGE, ROGUE WARRIOR, MAGE, ROGUE
} }

View File

@ -22,21 +22,20 @@
*/ */
package com.iluwatar.prototype; 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.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame; 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 * Date: 12/28/15 - 8:45 PM
* * @param <P> Prototype
* @author Jeroen Meulemeester * @author Jeroen Meulemeester
*/ */
@RunWith(Parameterized.class) @RunWith(Parameterized.class)

View File

@ -30,6 +30,10 @@ import org.slf4j.LoggerFactory;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
/**
* InMemory Log Appender Util.
*/
public class InMemoryAppender extends AppenderBase<ILoggingEvent> { public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
private List<ILoggingEvent> log = new LinkedList<>(); private List<ILoggingEvent> log = new LinkedList<>();

View File

@ -30,6 +30,9 @@ import org.slf4j.LoggerFactory;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
/**
* InMemory Log Appender Util.
*/
public class InMemoryAppender extends AppenderBase<ILoggingEvent> { public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
private List<ILoggingEvent> log = new LinkedList<>(); private List<ILoggingEvent> log = new LinkedList<>();

View File

@ -34,6 +34,9 @@ import org.springframework.data.jpa.domain.Specification;
*/ */
public class PersonSpecifications { public class PersonSpecifications {
/**
* Specifications stating the Between (From - To) Age Specification
*/
public static class AgeBetweenSpec implements Specification<Person> { public static class AgeBetweenSpec implements Specification<Person> {
private int from; private int from;

View File

@ -22,19 +22,18 @@
*/ */
package com.iluwatar.resource.acquisition.is.initialization; package com.iluwatar.resource.acquisition.is.initialization;
import static org.junit.Assert.assertTrue;
import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase; import ch.qos.logback.core.AppenderBase;
import java.util.LinkedList;
import java.util.List;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.LoggerFactory; 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 * Date: 12/28/15 - 9:31 PM
* *
@ -64,6 +63,9 @@ public class ClosableTest {
assertTrue(appender.logContains("Sliding door closes.")); assertTrue(appender.logContains("Sliding door closes."));
} }
/**
* Logging Appender Implementation
*/
public class InMemoryAppender extends AppenderBase<ILoggingEvent> { public class InMemoryAppender extends AppenderBase<ILoggingEvent> {
private List<ILoggingEvent> log = new LinkedList<>(); private List<ILoggingEvent> log = new LinkedList<>();

View File

@ -23,36 +23,39 @@
package com.iluwatar.semaphore; package com.iluwatar.semaphore;
/** /**
* Fruit is a resource stored in a FruitBowl. * Fruit is a resource stored in a FruitBowl.
*/ */
public class Fruit { public class Fruit {
/**
* Enumeration of Fruit Types
*/
public static enum FruitType { public static enum FruitType {
ORANGE, APPLE, LEMON ORANGE, APPLE, LEMON
} }
private FruitType type; private FruitType type;
public Fruit(FruitType type) { public Fruit(FruitType type) {
this.type = type; this.type = type;
} }
public FruitType getType() { public FruitType getType() {
return type; return type;
} }
/** /**
* toString method * toString method
*/ */
public String toString() { public String toString() {
switch (type) { switch (type) {
case ORANGE: case ORANGE:
return "Orange"; return "Orange";
case APPLE: case APPLE:
return "Apple"; return "Apple";
case LEMON: case LEMON:
return "Lemon"; return "Lemon";
default: default:
return ""; return "";
} }
} }

View File

@ -25,10 +25,13 @@ package com.iluwatar.semaphore;
import org.junit.Test; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
/**
* Application Test Entrypoint
*/
public class AppTest{ public class AppTest{
@Test @Test
public void test() throws IOException { public void test() throws IOException {
String[] args = {}; String[] args = {};
App.main(args); App.main(args);
} }
} }

View File

@ -22,23 +22,23 @@
*/ */
package com.iluwatar.servicelayer.common; 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.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; 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 * 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 * @author Jeroen Meulemeester
*/ */
public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>> { 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()); assertEquals(expectedName, entity.toString());
} }
} }

View File

@ -22,7 +22,8 @@
*/ */
package com.iluwatar.singleton; 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.ArrayList;
import java.util.List; import java.util.List;
@ -31,9 +32,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
/** /**
* This class provides several test case that test singleton construction. * 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. * the same when called in the DIFFERENT thread.
* *
* Date: 12/29/15 - 19:25 PM * Date: 12/29/15 - 19:25 PM
* * @param <S> Supplier method generating singletons
* @author Jeroen Meulemeester * @author Jeroen Meulemeester
* @author Richard Jones * @author Richard Jones
*/ */

View File

@ -22,23 +22,22 @@
*/ */
package com.iluwatar.templatemethod; 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.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase; import ch.qos.logback.core.AppenderBase;
import java.util.LinkedList;
import java.util.List;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.LoggerFactory; 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 * Date: 12/30/15 - 18:12 PM
* * @param <M> Type of StealingMethod
* @author Jeroen Meulemeester * @author Jeroen Meulemeester
*/ */
public abstract class StealingMethodTest<M extends StealingMethod> { public abstract class StealingMethodTest<M extends StealingMethod> {

View File

@ -22,7 +22,8 @@
*/ */
package com.iluwatar.threadpool; 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.ArrayList;
import java.util.List; import java.util.List;
@ -34,13 +35,12 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/** /**
* Date: 12/30/15 - 18:22 PM * Date: 12/30/15 - 18:22 PM
* * Test for Tasks using a Thread Pool
* @param <T> Type of Task
* @author Jeroen Meulemeester * @author Jeroen Meulemeester
*/ */
public abstract class TaskTest<T extends Task> { 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