This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StoryTest3 { | |
@Test | |
public void shouldReturnHobbitCharacters() { | |
List<Character> characters = new TestCharacterData().fellowshipOfTheRing(); | |
Story story = Story.builder().characters(characters).build(); | |
Set<Character> fellowshipOfRingHobbits = story.charactersOf(Race.HOBBIT); | |
assertThat(fellowshipOfRingHobbits).containsOnly(FRODO, SAM, MERRY, PIPPIN) | |
.extracting(Character::getRace) | |
.containsOnly(Race.HOBBIT); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StoryTest2 { | |
@Test | |
public void shouldReturnHobbitCharacters() { | |
List<Character> characters = Arrays.asList(BILBO, SAM, ARAGORN, GANDALF, FRODO); | |
Story story = Story.builder().characters(characters).build(); | |
Set<Character> storyHobbits = story.charactersOf(Race.HOBBIT); | |
assertThat(storyHobbits).containsOnly(BILBO, FRODO, SAM) | |
.extracting(Character::getRace) | |
.containsOnly(Race.HOBBIT); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StoryTest1 { | |
@Test | |
public void shouldReturnHobbitCharacters() { | |
List<Character> characters = new TestCharacterData().createList(); | |
Story story = Story.builder().characters(characters).build(); | |
Set<Character> storyHobbits = story.charactersOf(Race.HOBBIT); | |
assertThat(storyHobbits).containsOnly(BILBO, FRODO, SAM) | |
.extracting(Character::getRace) | |
.containsOnly(Race.HOBBIT); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example; | |
import com.sun.net.httpserver.HttpServer; | |
import java.io.OutputStream; | |
import java.net.InetSocketAddress; | |
import java.util.concurrent.Executors; | |
public class HelloWeb { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Class> buildClassHierarchy(Class baseClass) { | |
List<Class> superClasses = new ArrayList<>(); | |
Class clazz = baseClass; | |
while(neededInHierarchy(clazz)) { | |
superClasses.add(clazz); | |
clazz = clazz.getSuperclass(); | |
} | |
return superClasses; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Class> buildClassHierarchy(Class cls) { | |
List<Class> classHierarchy = new ArrayList<>(); | |
while (!Object.class.equals(cls) && cls != null) { | |
classHierarchy.add(cls); | |
cls = cls.getSuperclass(); | |
} | |
return classHierarchy; | |
} | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tom.futures; | |
import lombok.RequiredArgsConstructor; | |
import org.apache.commons.lang3.tuple.Pair; | |
import java.util.Random; | |
import java.util.concurrent.CompletableFuture; | |
import java.util.concurrent.Executor; | |
import java.util.concurrent.Executors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Zombie implements Compares<Zombie> | |
... remainder of Zombie code is unchanged | |
public class Zombie2Test { | |
Zombie walker = new Zombie(WALKER); | |
Zombie fatty = new Zombie(FATTY); | |
@Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Compares<T> extends Comparable<T> { | |
default boolean isLessThan(T other) { | |
return compareTo(other) < 0; | |
} | |
default boolean isGreaterThan(T other) { | |
return compareTo(other) > 0; | |
} |
NewerOlder