Java 11 migrate all remaining s (#1120)

* Moves saga to Java 11

* Moves semaphore to Java 11

* Moves servant to Java 11

* Moves serverless to Java 11

* Moves service-layer to Java 11

* Moves service-locator to Java 11

* Moves sharding to Java 11

* Moves singleton to Java 11

* Moves spatial-partition to Java 11

* Moves specification to Java 11

* Moves state to Java 11

* Moves step-builder to Java 11

* Moves strategy to Java 11

* Moves subclass-sandbox to Java 11

* Fixes checkstyle issues
This commit is contained in:
Anurag Agarwal
2020-01-04 22:06:08 +05:30
committed by Ilkka Seppälä
parent 310ae50248
commit cd2a2e7711
98 changed files with 718 additions and 855 deletions

View File

@ -28,16 +28,13 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
/**
*
* Application test
*
*/
public class AppTest {
@Test
public void test() {
String[] args = {};
App.main(args);
App.main(new String[]{});
}
@AfterEach

View File

@ -23,22 +23,20 @@
package com.iluwatar.servicelayer.common;
import com.iluwatar.servicelayer.hibernate.HibernateUtil;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import com.iluwatar.servicelayer.hibernate.HibernateUtil;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Date: 12/28/15 - 10:53 PM
* Test for Base Data Access Objects
* 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
@ -79,8 +77,8 @@ public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>
@BeforeEach
public void setUp() {
for (int i = 0; i < INITIAL_COUNT; i++) {
final String className = dao.persistentClass.getSimpleName();
final String entityName = String.format("%s%d", className, ID_GENERATOR.incrementAndGet());
final var className = dao.persistentClass.getSimpleName();
final var entityName = String.format("%s%d", className, ID_GENERATOR.incrementAndGet());
this.dao.persist(this.factory.apply(entityName));
}
}
@ -96,9 +94,9 @@ public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>
@Test
public void testFind() {
final List<E> all = this.dao.findAll();
for (final E entity : all) {
final E byId = this.dao.find(entity.getId());
final var all = this.dao.findAll();
for (final var entity : all) {
final var byId = this.dao.find(entity.getId());
assertNotNull(byId);
assertEquals(byId.getId(), byId.getId());
}
@ -106,39 +104,39 @@ public abstract class BaseDaoTest<E extends BaseEntity, D extends DaoBaseImpl<E>
@Test
public void testDelete() {
final List<E> originalEntities = this.dao.findAll();
final var originalEntities = this.dao.findAll();
this.dao.delete(originalEntities.get(1));
this.dao.delete(originalEntities.get(2));
final List<E> entitiesLeft = this.dao.findAll();
final var entitiesLeft = this.dao.findAll();
assertNotNull(entitiesLeft);
assertEquals(INITIAL_COUNT - 2, entitiesLeft.size());
}
@Test
public void testFindAll() {
final List<E> all = this.dao.findAll();
final var all = this.dao.findAll();
assertNotNull(all);
assertEquals(INITIAL_COUNT, all.size());
}
@Test
public void testSetId() {
final E entity = this.factory.apply("name");
final var entity = this.factory.apply("name");
assertNull(entity.getId());
final Long expectedId = 1L;
final var expectedId = 1L;
entity.setId(expectedId);
assertEquals(expectedId, entity.getId());
}
@Test
public void testSetName() {
final E entity = this.factory.apply("name");
final var entity = this.factory.apply("name");
assertEquals("name", entity.getName());
assertEquals("name", entity.toString());
final String expectedName = "new name";
final var expectedName = "new name";
entity.setName(expectedName);
assertEquals(expectedName, entity.getName());
assertEquals(expectedName, entity.toString());

View File

@ -23,18 +23,6 @@
package com.iluwatar.servicelayer.magic;
import com.iluwatar.servicelayer.spell.Spell;
import com.iluwatar.servicelayer.spell.SpellDao;
import com.iluwatar.servicelayer.spellbook.Spellbook;
import com.iluwatar.servicelayer.spellbook.SpellbookDao;
import com.iluwatar.servicelayer.wizard.Wizard;
import com.iluwatar.servicelayer.wizard.WizardDao;
import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Matchers.eq;
@ -44,6 +32,15 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import com.iluwatar.servicelayer.spell.Spell;
import com.iluwatar.servicelayer.spell.SpellDao;
import com.iluwatar.servicelayer.spellbook.Spellbook;
import com.iluwatar.servicelayer.spellbook.SpellbookDao;
import com.iluwatar.servicelayer.wizard.Wizard;
import com.iluwatar.servicelayer.wizard.WizardDao;
import java.util.Set;
import org.junit.jupiter.api.Test;
/**
* Date: 12/29/15 - 12:06 AM
*
@ -53,11 +50,11 @@ public class MagicServiceImplTest {
@Test
public void testFindAllWizards() {
final WizardDao wizardDao = mock(WizardDao.class);
final SpellbookDao spellbookDao = mock(SpellbookDao.class);
final SpellDao spellDao = mock(SpellDao.class);
final var wizardDao = mock(WizardDao.class);
final var spellbookDao = mock(SpellbookDao.class);
final var spellDao = mock(SpellDao.class);
final MagicServiceImpl service = new MagicServiceImpl(wizardDao, spellbookDao, spellDao);
final var service = new MagicServiceImpl(wizardDao, spellbookDao, spellDao);
verifyZeroInteractions(wizardDao, spellbookDao, spellDao);
service.findAllWizards();
@ -66,12 +63,12 @@ public class MagicServiceImplTest {
}
@Test
public void testFindAllSpellbooks() throws Exception {
final WizardDao wizardDao = mock(WizardDao.class);
final SpellbookDao spellbookDao = mock(SpellbookDao.class);
final SpellDao spellDao = mock(SpellDao.class);
public void testFindAllSpellbooks() {
final var wizardDao = mock(WizardDao.class);
final var spellbookDao = mock(SpellbookDao.class);
final var spellDao = mock(SpellDao.class);
final MagicServiceImpl service = new MagicServiceImpl(wizardDao, spellbookDao, spellDao);
final var service = new MagicServiceImpl(wizardDao, spellbookDao, spellDao);
verifyZeroInteractions(wizardDao, spellbookDao, spellDao);
service.findAllSpellbooks();
@ -80,12 +77,12 @@ public class MagicServiceImplTest {
}
@Test
public void testFindAllSpells() throws Exception {
final WizardDao wizardDao = mock(WizardDao.class);
final SpellbookDao spellbookDao = mock(SpellbookDao.class);
final SpellDao spellDao = mock(SpellDao.class);
public void testFindAllSpells() {
final var wizardDao = mock(WizardDao.class);
final var spellbookDao = mock(SpellbookDao.class);
final var spellDao = mock(SpellDao.class);
final MagicServiceImpl service = new MagicServiceImpl(wizardDao, spellbookDao, spellDao);
final var service = new MagicServiceImpl(wizardDao, spellbookDao, spellDao);
verifyZeroInteractions(wizardDao, spellbookDao, spellDao);
service.findAllSpells();
@ -94,26 +91,27 @@ public class MagicServiceImplTest {
}
@Test
public void testFindWizardsWithSpellbook() throws Exception {
final String bookname = "bookname";
final Spellbook spellbook = mock(Spellbook.class);
final Set<Wizard> wizards = Set.of(
mock(Wizard.class),
mock(Wizard.class),
mock(Wizard.class));
public void testFindWizardsWithSpellbook() {
final var bookname = "bookname";
final var spellbook = mock(Spellbook.class);
final var wizards = Set.of(
mock(Wizard.class),
mock(Wizard.class),
mock(Wizard.class)
);
when(spellbook.getWizards()).thenReturn(wizards);
final SpellbookDao spellbookDao = mock(SpellbookDao.class);
final var spellbookDao = mock(SpellbookDao.class);
when(spellbookDao.findByName(eq(bookname))).thenReturn(spellbook);
final WizardDao wizardDao = mock(WizardDao.class);
final SpellDao spellDao = mock(SpellDao.class);
final var wizardDao = mock(WizardDao.class);
final var spellDao = mock(SpellDao.class);
final MagicServiceImpl service = new MagicServiceImpl(wizardDao, spellbookDao, spellDao);
final var service = new MagicServiceImpl(wizardDao, spellbookDao, spellDao);
verifyZeroInteractions(wizardDao, spellbookDao, spellDao, spellbook);
final List<Wizard> result = service.findWizardsWithSpellbook(bookname);
final var result = service.findWizardsWithSpellbook(bookname);
verify(spellbookDao).findByName(eq(bookname));
verify(spellbook).getWizards();
@ -125,27 +123,28 @@ public class MagicServiceImplTest {
@Test
public void testFindWizardsWithSpell() throws Exception {
final Set<Wizard> wizards = Set.of(
mock(Wizard.class),
mock(Wizard.class),
mock(Wizard.class));
final Spellbook spellbook = mock(Spellbook.class);
final var wizards = Set.of(
mock(Wizard.class),
mock(Wizard.class),
mock(Wizard.class)
);
final var spellbook = mock(Spellbook.class);
when(spellbook.getWizards()).thenReturn(wizards);
final SpellbookDao spellbookDao = mock(SpellbookDao.class);
final WizardDao wizardDao = mock(WizardDao.class);
final var spellbookDao = mock(SpellbookDao.class);
final var wizardDao = mock(WizardDao.class);
final Spell spell = mock(Spell.class);
final var spell = mock(Spell.class);
when(spell.getSpellbook()).thenReturn(spellbook);
final String spellName = "spellname";
final SpellDao spellDao = mock(SpellDao.class);
final var spellName = "spellname";
final var spellDao = mock(SpellDao.class);
when(spellDao.findByName(eq(spellName))).thenReturn(spell);
final MagicServiceImpl service = new MagicServiceImpl(wizardDao, spellbookDao, spellDao);
final var service = new MagicServiceImpl(wizardDao, spellbookDao, spellDao);
verifyZeroInteractions(wizardDao, spellbookDao, spellDao, spellbook);
final List<Wizard> result = service.findWizardsWithSpell(spellName);
final var result = service.findWizardsWithSpell(spellName);
verify(spellDao).findByName(eq(spellName));
verify(spellbook).getWizards();

View File

@ -23,14 +23,12 @@
package com.iluwatar.servicelayer.spell;
import com.iluwatar.servicelayer.common.BaseDaoTest;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import com.iluwatar.servicelayer.common.BaseDaoTest;
import org.junit.jupiter.api.Test;
/**
* Date: 12/28/15 - 11:02 PM
*
@ -44,10 +42,10 @@ public class SpellDaoImplTest extends BaseDaoTest<Spell, SpellDaoImpl> {
@Test
public void testFindByName() {
final SpellDaoImpl dao = getDao();
final List<Spell> allSpells = dao.findAll();
for (final Spell spell : allSpells) {
final Spell spellByName = dao.findByName(spell.getName());
final var dao = getDao();
final var allSpells = dao.findAll();
for (final var spell : allSpells) {
final var spellByName = dao.findByName(spell.getName());
assertNotNull(spellByName);
assertEquals(spell.getId(), spellByName.getId());
assertEquals(spell.getName(), spellByName.getName());

View File

@ -23,14 +23,12 @@
package com.iluwatar.servicelayer.spellbook;
import com.iluwatar.servicelayer.common.BaseDaoTest;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import com.iluwatar.servicelayer.common.BaseDaoTest;
import org.junit.jupiter.api.Test;
/**
* Date: 12/28/15 - 11:44 PM
*
@ -44,10 +42,10 @@ public class SpellbookDaoImplTest extends BaseDaoTest<Spellbook, SpellbookDaoImp
@Test
public void testFindByName() {
final SpellbookDaoImpl dao = getDao();
final List<Spellbook> allBooks = dao.findAll();
for (final Spellbook book : allBooks) {
final Spellbook spellByName = dao.findByName(book.getName());
final var dao = getDao();
final var allBooks = dao.findAll();
for (final var book : allBooks) {
final var spellByName = dao.findByName(book.getName());
assertNotNull(spellByName);
assertEquals(book.getId(), spellByName.getId());
assertEquals(book.getName(), spellByName.getName());

View File

@ -23,14 +23,12 @@
package com.iluwatar.servicelayer.wizard;
import com.iluwatar.servicelayer.common.BaseDaoTest;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import com.iluwatar.servicelayer.common.BaseDaoTest;
import org.junit.jupiter.api.Test;
/**
* Date: 12/28/15 - 11:46 PM
*
@ -44,10 +42,10 @@ public class WizardDaoImplTest extends BaseDaoTest<Wizard, WizardDaoImpl> {
@Test
public void testFindByName() {
final WizardDaoImpl dao = getDao();
final List<Wizard> allWizards = dao.findAll();
for (final Wizard spell : allWizards) {
final Wizard byName = dao.findByName(spell.getName());
final var dao = getDao();
final var allWizards = dao.findAll();
for (final var spell : allWizards) {
final var byName = dao.findByName(spell.getName());
assertNotNull(byName);
assertEquals(spell.getId(), byName.getId());
assertEquals(spell.getName(), byName.getName());