Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 11 migrate all remaining s #1120

Merged
merged 16 commits into from
Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Moves step-builder to Java 11
  • Loading branch information
anuragagarwal561994 committed Dec 28, 2019
commit 53aa4d8fa5c7e702a3ea6c11726f86373665c1d3
31 changes: 22 additions & 9 deletions step-builder/src/main/java/com/iluwatar/stepbuilder/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,34 @@ public class App {
*/
public static void main(String[] args) {

var warrior =
CharacterStepBuilder.newBuilder().name("Amberjill").fighterClass("Paladin")
.withWeapon("Sword").noAbilities().build();
var warrior = CharacterStepBuilder
.newBuilder()
.name("Amberjill")
.fighterClass("Paladin")
.withWeapon("Sword")
.noAbilities()
.build();

LOGGER.info(warrior.toString());

var mage =
CharacterStepBuilder.newBuilder().name("Riobard").wizardClass("Sorcerer")
.withSpell("Fireball").withAbility("Fire Aura").withAbility("Teleport")
.noMoreAbilities().build();
var mage = CharacterStepBuilder
.newBuilder()
.name("Riobard")
.wizardClass("Sorcerer")
.withSpell("Fireball")
.withAbility("Fire Aura")
.withAbility("Teleport")
.noMoreAbilities()
.build();

LOGGER.info(mage.toString());

var thief =
CharacterStepBuilder.newBuilder().name("Desmond").fighterClass("Rogue").noWeapon().build();
var thief = CharacterStepBuilder
.newBuilder()
.name("Desmond")
.fighterClass("Rogue")
.noWeapon()
.build();

LOGGER.info(thief.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ public void setAbilities(List<String> abilities) {

@Override
public String toString() {
var sb = new StringBuilder();
sb.append("This is a ")
return new StringBuilder()
.append("This is a ")
.append(fighterClass != null ? fighterClass : wizardClass)
.append(" named ")
.append(name)
.append(" armed with a ")
.append(weapon != null ? weapon : spell != null ? spell : "with nothing")
.append(abilities != null ? " and wielding " + abilities + " abilities" : "")
.append('.');
return sb.toString();
.append('.')
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public BuildStep noAbilities() {

@Override
public Character build() {
Character character = new Character(name);
var character = new Character(name);

if (fighterClass != null) {
character.setFighterClass(fighterClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,12 @@
import org.junit.jupiter.api.Test;

/**
*
* Application test
*
*/
public class AppTest {

@Test
public void test() {
String[] args = {};
App.main(args);
App.main(new String[]{});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@

package com.iluwatar.stepbuilder;

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 static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

/**
* Date: 12/29/15 - 9:21 PM
*
Expand All @@ -44,7 +42,7 @@ public class CharacterStepBuilderTest {
*/
@Test
public void testBuildWizard() {
final Character character = CharacterStepBuilder.newBuilder()
final var character = CharacterStepBuilder.newBuilder()
.name("Merlin")
.wizardClass("alchemist")
.withSpell("poison")
Expand All @@ -58,7 +56,7 @@ public void testBuildWizard() {
assertEquals("poison", character.getSpell());
assertNotNull(character.toString());

final List<String> abilities = character.getAbilities();
final var abilities = character.getAbilities();
assertNotNull(abilities);
assertEquals(2, abilities.size());
assertTrue(abilities.contains("invisibility"));
Expand All @@ -72,7 +70,7 @@ public void testBuildWizard() {
*/
@Test
public void testBuildPoorWizard() {
final Character character = CharacterStepBuilder.newBuilder()
final var character = CharacterStepBuilder.newBuilder()
.name("Merlin")
.wizardClass("alchemist")
.noSpell()
Expand All @@ -91,7 +89,7 @@ public void testBuildPoorWizard() {
*/
@Test
public void testBuildWeakWizard() {
final Character character = CharacterStepBuilder.newBuilder()
final var character = CharacterStepBuilder.newBuilder()
.name("Merlin")
.wizardClass("alchemist")
.withSpell("poison")
Expand All @@ -112,7 +110,7 @@ public void testBuildWeakWizard() {
*/
@Test
public void testBuildWarrior() {
final Character character = CharacterStepBuilder.newBuilder()
final var character = CharacterStepBuilder.newBuilder()
.name("Cuauhtemoc")
.fighterClass("aztec")
.withWeapon("spear")
Expand All @@ -126,7 +124,7 @@ public void testBuildWarrior() {
assertEquals("spear", character.getWeapon());
assertNotNull(character.toString());

final List<String> abilities = character.getAbilities();
final var abilities = character.getAbilities();
assertNotNull(abilities);
assertEquals(2, abilities.size());
assertTrue(abilities.contains("speed"));
Expand All @@ -140,7 +138,7 @@ public void testBuildWarrior() {
*/
@Test
public void testBuildPoorWarrior() {
final Character character = CharacterStepBuilder.newBuilder()
final var character = CharacterStepBuilder.newBuilder()
.name("Poor warrior")
.fighterClass("none")
.noWeapon()
Expand All @@ -160,7 +158,7 @@ public void testBuildPoorWarrior() {
*/
@Test
public void testBuildWeakWarrior() {
final Character character = CharacterStepBuilder.newBuilder()
final var character = CharacterStepBuilder.newBuilder()
.name("Weak warrior")
.fighterClass("none")
.withWeapon("Slingshot")
Expand Down