Repository: iluwatar/java-design-patterns
Issue: Object Mother pattern
Labels: epic: pattern
info: good first issue

http://martinfowler.com/bliki/ObjectMother.html


Issue comments:
Hi! Great library :+1: 
I want to take this one but what is the main difference to a simple [factory pattern](https://www.tutorialspoint.com/design_pattern/factory_pattern.htm)?

Since the link you shared was working with employees i have thought for something like this:

``` java
EmployeeMother mother = new EmployeeMother();
Employee heather = mother.bear(EmployeeName.HEATHER);
Employee heather = mother.bear(EmployeeName.JOHN);
```

where EmployeeName is an enumeration of names. Is this the right approach?

@igeligel some elaboration here http://stackoverflow.com/questions/923319/what-is-an-objectmother. I'll change to labels to indicate you're working on it.

Yeah i want to work on this. I will probably code it the next days and check for a code review here then (i will announce if i think it is ready).

Edit: Thanks for the response :+1: 

I have made the first try. The only thing that has not worked yet is the PlantUML diagram. I will try to make this tomorrow and commit to the fork again. A code review would be appreciated :)

Don't worry about the PlantUML diagram - it is still experimental and we don't check it when you make the pull request. ObjectAid diagram is the one you should generate, as per instructions here https://github.com/iluwatar/java-design-patterns/wiki/01.-How-to-contribute


Pull request review comments:
Confusing naming here

Confusing naming here

Confusing naming here


Patch that resolved the issue:
diff --git a/object-mother/README.md b/object-mother/README.md
new file mode 100644
index 000000000000..9188c8b4128d
--- /dev/null
+++ b/object-mother/README.md
@@ -0,0 +1,31 @@
+---
+layout: pattern
+title: Object Mother
+folder: object-mother
+permalink: /patterns/object-mother/
+pumlid: 
+categories: Creational
+tags:
+ - Java
+ - Difficulty-Beginner
+---
+
+## Object Mother
+Define a factory of immutable content with separated builder and factory interfaces.
+
+![alt text](./etc/object-mother.png "Object Mother")
+
+## Applicability
+Use the Object Mother pattern when
+
+* You want consistent objects over several tests
+* you want to reduce code for creation of objects in tests
+* every test should run with fresh data
+
+## Credits
+
+* [Answer by David Brown](http://stackoverflow.com/questions/923319/what-is-an-objectmother) to the stackoverflow question: [What is an ObjectMother?](http://stackoverflow.com/questions/923319/what-is-an-objectmother)
+
+* [c2wiki - Object Mother](http://c2.com/cgi/wiki?ObjectMother)
+
+* [Nat Pryce - Test Data Builders: an alternative to the Object Mother pattern](http://www.natpryce.com/articles/000714.html)
\ No newline at end of file
diff --git a/object-mother/etc/object-mother.ucls b/object-mother/etc/object-mother.ucls
new file mode 100644
index 000000000000..ef6cee5eff45
--- /dev/null
+++ b/object-mother/etc/object-mother.ucls
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<class-diagram version="1.1.11" icons="true" automaticImage="PNG" always-add-relationships="false" 
+  generalizations="true" realizations="true" associations="true" dependencies="false" nesting-relationships="true" 
+  router="FAN">  
+  <class id="1" language="java" name="com.iluwatar.objectmother.RoyaltyObjectMother" project="object-mother" 
+    file="/object-mother/src/main/java/com/iluwatar/objectmother/RoyaltyObjectMother.java" binary="false" 
+    corner="BOTTOM_RIGHT">    
+    <position height="-1" width="-1" x="535" y="366"/>    
+    <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" 
+      sort-features="false" accessors="true" visibility="true">      
+      <attributes public="true" package="true" protected="true" private="true" static="true"/>      
+      <operations public="true" package="true" protected="true" private="true" static="true"/>    
+    </display>  
+  </class>  
+  <class id="2" language="java" name="com.iluwatar.objectmother.King" project="object-mother" 
+    file="/object-mother/src/main/java/com/iluwatar/objectmother/King.java" binary="false" corner="BOTTOM_RIGHT">    
+    <position height="-1" width="-1" x="285" y="141"/>    
+    <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" 
+      sort-features="false" accessors="true" visibility="true">      
+      <attributes public="true" package="true" protected="true" private="true" static="true"/>      
+      <operations public="true" package="true" protected="true" private="true" static="true"/>    
+    </display>  
+  </class>  
+  <class id="3" language="java" name="com.iluwatar.objectmother.Queen" project="object-mother" 
+    file="/object-mother/src/main/java/com/iluwatar/objectmother/Queen.java" binary="false" corner="BOTTOM_RIGHT">    
+    <position height="-1" width="-1" x="783" y="143"/>    
+    <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" 
+      sort-features="false" accessors="true" visibility="true">      
+      <attributes public="true" package="true" protected="true" private="true" static="true"/>      
+      <operations public="true" package="true" protected="true" private="true" static="true"/>    
+    </display>  
+  </class>  
+  <interface id="4" language="java" name="com.iluwatar.objectmother.Royalty" project="object-mother" 
+    file="/object-mother/src/main/java/com/iluwatar/objectmother/Royalty.java" binary="false" corner="BOTTOM_RIGHT">    
+    <position height="-1" width="-1" x="536" y="142"/>    
+    <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" 
+      sort-features="false" accessors="true" visibility="true">      
+      <attributes public="true" package="true" protected="true" private="true" static="true"/>      
+      <operations public="true" package="true" protected="true" private="true" static="true"/>    
+    </display>  
+  </interface>  
+  <realization id="5">    
+    <end type="SOURCE" refId="2"/>    
+    <end type="TARGET" refId="4"/>  
+  </realization>  
+  <realization id="6">    
+    <end type="SOURCE" refId="3"/>    
+    <end type="TARGET" refId="4"/>  
+  </realization>  
+  <classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" 
+    sort-features="false" accessors="true" visibility="true">    
+    <attributes public="true" package="true" protected="true" private="true" static="true"/>    
+    <operations public="true" package="true" protected="true" private="true" static="true"/>  
+  </classifier-display>  
+  <association-display labels="true" multiplicity="true"/>
+</class-diagram>
\ No newline at end of file
diff --git a/object-mother/etc/object-mother.urm.puml b/object-mother/etc/object-mother.urm.puml
new file mode 100644
index 000000000000..9b26450f065f
--- /dev/null
+++ b/object-mother/etc/object-mother.urm.puml
@@ -0,0 +1,45 @@
+@startuml
+package com.iluwatar.objectmother {
+  class RoyaltyObjectMother {
+    + RoyaltyObjectMother()
+    + createDrunkKing() : King {static}
+    + createFlirtyQueen() : Queen {static}
+    + createHappyDrunkKing() : King {static}
+    + createHappyKing() : King {static}
+    + createNotFlirtyQueen() : Queen {static}
+    + createSoberUnhappyKing() : King {static}
+  }
+  class Queen {
+    - isDrunk : boolean
+    - isFlirty : boolean
+    - isHappy : boolean
+    + Queen()
+    + getFlirted(king : King) : boolean
+    + isFlirty() : boolean
+    + makeDrunk()
+    + makeHappy()
+    + makeSober()
+    + makeUnhappy()
+    + setFlirtiness(flirtiness : boolean)
+  }
+  interface Royalty {
+    + makeDrunk() {abstract}
+    + makeHappy() {abstract}
+    + makeSober() {abstract}
+    + makeUnhappy() {abstract}
+  }
+  class King {
+    ~ isDrunk : boolean
+    ~ isHappy : boolean
+    + King()
+    + flirt(queen : Queen)
+    + isHappy() : boolean
+    + makeDrunk()
+    + makeHappy()
+    + makeSober()
+    + makeUnhappy()
+  }
+}
+Queen ..|> Royalty 
+King ..|> Royalty 
+@enduml
\ No newline at end of file
diff --git a/object-mother/pom.xml b/object-mother/pom.xml
new file mode 100644
index 000000000000..91bdff8e24dc
--- /dev/null
+++ b/object-mother/pom.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<!--
+
+    The MIT License
+    Copyright (c) 2016 Ilkka Seppälä
+
+    Permission is hereby granted, free of charge, to any person obtaining a copy
+    of this software and associated documentation files (the "Software"), to deal
+    in the Software without restriction, including without limitation the rights
+    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+    copies of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+    THE SOFTWARE.
+
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.iluwatar</groupId>
+        <artifactId>java-design-patterns</artifactId>
+        <version>1.14.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>object-mother</artifactId>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file
diff --git a/object-mother/src/main/java/com/iluwatar/objectmother/King.java b/object-mother/src/main/java/com/iluwatar/objectmother/King.java
new file mode 100644
index 000000000000..544b0bacba8c
--- /dev/null
+++ b/object-mother/src/main/java/com/iluwatar/objectmother/King.java
@@ -0,0 +1,66 @@
+/**
+ * The MIT License
+ * Copyright (c) 2016 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.objectmother;
+
+public class King implements Royalty {
+  boolean isDrunk = false;
+  boolean isHappy = false;
+
+  @Override
+  public void makeDrunk() {
+    isDrunk = true;
+  }
+
+  @Override
+  public void makeSober() {
+    isDrunk = false;
+  }
+
+  @Override
+  public void makeHappy() {
+    isHappy = true;
+  }
+
+  @Override
+  public void makeUnhappy() {
+    isHappy = false;
+  }
+  
+  public boolean isHappy() {
+    return isHappy;
+  }
+  
+  /**
+   * Method to flirt to a queen.
+   * @param queen Queen which should be flirted.
+   */
+  public void flirt(Queen queen) {
+    boolean flirtStatus = queen.getFlirted(this);
+    if (flirtStatus == false) {
+      this.makeUnhappy();
+    } else {
+      this.makeHappy();
+    }
+    
+  }
+}
diff --git a/object-mother/src/main/java/com/iluwatar/objectmother/Queen.java b/object-mother/src/main/java/com/iluwatar/objectmother/Queen.java
new file mode 100644
index 000000000000..3e18fbf3a902
--- /dev/null
+++ b/object-mother/src/main/java/com/iluwatar/objectmother/Queen.java
@@ -0,0 +1,69 @@
+/**
+ * The MIT License
+ * Copyright (c) 2016 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.objectmother;
+
+public class Queen implements Royalty {
+  private boolean isDrunk = false;
+  private boolean isHappy = false;
+  private boolean isFlirty = false;
+
+  @Override
+  public void makeDrunk() {
+    isDrunk = true;
+  }
+
+  @Override
+  public void makeSober() {
+    isDrunk = false;
+  }
+
+  @Override
+  public void makeHappy() {
+    isHappy = true;
+  }
+
+  @Override
+  public void makeUnhappy() {
+    isHappy = false;
+  }
+  
+  public boolean isFlirty() {
+    return isFlirty;
+  }
+
+  public void setFlirtiness(boolean flirtiness) {
+    this.isFlirty = flirtiness;
+  }
+  
+  /**
+   * Method which is called when the king is flirting to a queen.
+   * @param king King who initialized the flirt.
+   * @return A value which describes if the flirt was successful or not.
+   */
+  public boolean getFlirted(King king) {
+    if (this.isFlirty && king.isHappy && !king.isDrunk) {
+      return true;
+    }
+    return false;
+  }
+}
diff --git a/object-mother/src/main/java/com/iluwatar/objectmother/Royalty.java b/object-mother/src/main/java/com/iluwatar/objectmother/Royalty.java
new file mode 100644
index 000000000000..2bebc093991f
--- /dev/null
+++ b/object-mother/src/main/java/com/iluwatar/objectmother/Royalty.java
@@ -0,0 +1,33 @@
+/**
+ * The MIT License
+ * Copyright (c) 2016 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.objectmother;
+
+public interface Royalty {
+  void makeDrunk();
+  
+  void makeSober();
+  
+  void makeHappy();
+  
+  void makeUnhappy();
+}
diff --git a/object-mother/src/main/java/com/iluwatar/objectmother/RoyaltyObjectMother.java b/object-mother/src/main/java/com/iluwatar/objectmother/RoyaltyObjectMother.java
new file mode 100644
index 000000000000..624a29132531
--- /dev/null
+++ b/object-mother/src/main/java/com/iluwatar/objectmother/RoyaltyObjectMother.java
@@ -0,0 +1,83 @@
+/**
+ * The MIT License
+ * Copyright (c) 2016 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.objectmother;
+
+public final class RoyaltyObjectMother {
+  
+  /**
+   * Method to create a sober and unhappy king. The standard paramters are set.
+   * @return An instance of {@link com.iluwatar.objectmother.King} with the standard properties.
+   */
+  public static King createSoberUnhappyKing() {
+    return new King();
+  }
+  
+  /**
+   * Method of the object mother to create a drunk king.
+   * @return A drunk {@link com.iluwatar.objectmother.King}.
+   */
+  public static King createDrunkKing() {
+    King king = new King();
+    king.makeDrunk();
+    return king;
+  }
+  
+  /**
+   * Method to create a happy king.
+   * @return A happy {@link com.iluwatar.objectmother.King}.
+   */
+  public static King createHappyKing() {
+    King king = new King();
+    king.makeHappy();
+    return king;
+  }
+  
+  /**
+   * Method to create a happy and drunk king.
+   * @return A drunk and happy {@link com.iluwatar.objectmother.King}.
+   */
+  public static King createHappyDrunkKing() {
+    King king = new King();
+    king.makeHappy();
+    king.makeDrunk();
+    return king;
+  }
+  
+  /**
+   * Method to create a flirty queen.
+   * @return A flirty {@link com.iluwatar.objectmother.Queen}.
+   */
+  public static Queen createFlirtyQueen() {
+    Queen queen = new Queen();
+    queen.setFlirtiness(true);
+    return queen;
+  }
+  
+  /**
+   * Method to create a not flirty queen.
+   * @return A not flirty {@link com.iluwatar.objectmother.Queen}.
+   */
+  public static Queen createNotFlirtyQueen() {
+    return new Queen();
+  }
+}
diff --git a/pom.xml b/pom.xml
index 538058a81988..76e108a57c50 100644
--- a/pom.xml
+++ b/pom.xml
@@ -133,7 +133,8 @@
         <module>promise</module>
         <module>page-object</module>
         <module>event-asynchronous</module>
-	</modules>
+        <module>object-mother</module>
+    </modules>
 
     <dependencyManagement>
         <dependencies>


Test patch:
diff --git a/object-mother/src/test/java/com/iluwatar/objectmother/test/RoyaltyObjectMotherTest.java b/object-mother/src/test/java/com/iluwatar/objectmother/test/RoyaltyObjectMotherTest.java
new file mode 100644
index 000000000000..ebe536d24bcc
--- /dev/null
+++ b/object-mother/src/test/java/com/iluwatar/objectmother/test/RoyaltyObjectMotherTest.java
@@ -0,0 +1,89 @@
+/**
+ * The MIT License
+ * Copyright (c) 2016 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.objectmother.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.iluwatar.objectmother.King;
+import com.iluwatar.objectmother.Queen;
+import com.iluwatar.objectmother.Royalty;
+import com.iluwatar.objectmother.RoyaltyObjectMother;
+
+public class RoyaltyObjectMotherTest {
+  
+  @Test
+  public void unsuccessfulKingFlirt() {
+    King soberUnhappyKing = RoyaltyObjectMother.createSoberUnhappyKing();
+    Queen flirtyQueen = RoyaltyObjectMother.createFlirtyQueen();
+    soberUnhappyKing.flirt(flirtyQueen);
+    assertFalse(soberUnhappyKing.isHappy());
+  }
+  
+  @Test
+  public void queenIsBlockingFlirtCauseDrunkKing() {
+    King drunkUnhappyKing = RoyaltyObjectMother.createDrunkKing();
+    Queen notFlirtyQueen = RoyaltyObjectMother.createNotFlirtyQueen();
+    drunkUnhappyKing.flirt(notFlirtyQueen);
+    assertFalse(drunkUnhappyKing.isHappy());
+  }
+  
+  @Test
+  public void queenIsBlockingFlirt() {
+    King soberHappyKing = RoyaltyObjectMother.createHappyKing();
+    Queen notFlirtyQueen = RoyaltyObjectMother.createNotFlirtyQueen();
+    soberHappyKing.flirt(notFlirtyQueen);
+    assertFalse(soberHappyKing.isHappy());
+  }
+  
+  @Test
+  public void successfullKingFlirt() {
+    King soberHappyKing = RoyaltyObjectMother.createHappyKing();
+    Queen flirtyQueen = RoyaltyObjectMother.createFlirtyQueen();
+    soberHappyKing.flirt(flirtyQueen);
+    assertTrue(soberHappyKing.isHappy());
+  }
+  
+  @Test
+  public void testQueenType() {
+    Royalty flirtyQueen = RoyaltyObjectMother.createFlirtyQueen();
+    Royalty notFlirtyQueen = RoyaltyObjectMother.createNotFlirtyQueen();
+    assertEquals(flirtyQueen.getClass(), Queen.class);
+    assertEquals(notFlirtyQueen.getClass(), Queen.class);
+  }
+  
+  @Test
+  public void testKingType() {
+    Royalty drunkKing = RoyaltyObjectMother.createDrunkKing();
+    Royalty happyDrunkKing = RoyaltyObjectMother.createHappyDrunkKing();
+    Royalty happyKing = RoyaltyObjectMother.createHappyKing();
+    Royalty soberUnhappyKing = RoyaltyObjectMother.createSoberUnhappyKing();
+    assertEquals(drunkKing.getClass(), King.class);
+    assertEquals(happyDrunkKing.getClass(), King.class);
+    assertEquals(happyKing.getClass(), King.class);
+    assertEquals(soberUnhappyKing.getClass(), King.class);
+  }
+}