package com.github.bot.curiosone.core.workflow;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Test;

public class MessageTest {

  @Test
  public void testGetMessage() {
    Message m = new Message("This is the message!", "This is the scope", "");
    assertThat(m.getMessage()).isEqualTo("This is the message!");

    m = new Message("", "This is the scope", "");
    assertThat(m.getMessage()).isEmpty();

    m = new Message("  ..  ", "This is the scope", "");
    assertThat(m.getMessage()).isEqualTo("  ..  ");
  }

  @Test
  public void testGetScope() {
    Message m = new Message("This is the message!", "This is the scope", "");
    assertThat(m.getScope()).isEqualTo("This is the scope");

    m = new Message("This is the message!", "  ", "");
    assertThat(m.getScope()).isEqualTo("  ");

    m = new Message("This is the message!", "", "");
    assertThat(m.getScope()).isEmpty();
  }

  @Test
  public void testToString() {
    Message m = new Message("Text", "Scope", "Emotion");
    assertThat(m.toString()).isEqualTo("Text (Scope)[Emotion]");

    m = new Message("I am a human", "human", "");
    assertThat(m.toString()).isEqualTo("I am a human (human)[]");

    m = new Message("Do you live here?", "here?", "");
    assertThat(m.toString()).isEqualTo("Do you live here? (here?)[]");

    m = new Message("", "", "");
    assertThat(m.toString()).isEqualTo(" ()[]");
  }

  @Test
  public void testEqualsReflexive() {
    Message m = new Message("Text", "Scope", "");
    assertThat(m).isEqualTo(m);

    m = new Message("", "", "");
    assertThat(m).isEqualTo(m);

    m = new Message(" ", " ", "");
    assertThat(m).isEqualTo(m);
  }

  @Test
  public void testEqualsSymmetric() {
    Message m = new Message("Text", "Scope", "");
    Message mm = new Message("Text", "Scope", "");
    assertThat(m).isEqualTo(mm);
    assertThat(mm).isEqualTo(m);

    m = new Message(" ", " ", "");
    mm = new Message(" ", " ", "");
    assertThat(m).isEqualTo(mm);
    assertThat(mm).isEqualTo(m);

    m = new Message("a", "b", "");
    mm = new Message("c", "d", "");
    assertThat(m).isNotEqualTo(mm);
    assertThat(mm).isNotEqualTo(m);
  }

  @Test
  public void testEqualsTransitive() {
    Message m = new Message("Text", "Scope", "");
    Message mm = new Message("Text", "Scope", "");
    Message mmm = new Message("Text", "Scope", "");
    assertThat(m).isEqualTo(mm);
    assertThat(mm).isEqualTo(mmm);
    assertThat(mmm).isEqualTo(m);

    m = new Message("", "", "");
    mm = new Message("", "", "");
    mmm = new Message("", "", "");
    assertThat(m).isEqualTo(mm);
    assertThat(mm).isEqualTo(mmm);
    assertThat(mmm).isEqualTo(m);

    m = new Message("1234", "numbers", "");
    mm = new Message("1234", "numbers", "");
    mmm = new Message("1234", "numbers", "");
    assertThat(m).isEqualTo(mm);
    assertThat(mm).isEqualTo(mmm);
    assertThat(mmm).isEqualTo(m);
  }

  @Test
  public void testEqualsOtherObj() {
    Message m = new Message("Text", "Scope", "");

    assertThat(m).isNotEqualTo("TEXT - SCOPE");

    assertThat(m).isNotEqualTo(new StringBuffer("  , , "));

    assertThat(m).isNotEqualTo(42);
  }

  @Test
  public void testHashCodeReflexive() {
    Message m = new Message("Text", "Scope", "");
    assertThat(m.hashCode()).isEqualTo(m.hashCode());

    m = new Message("I am eating an apple", "apple", "");
    assertThat(m.hashCode()).isEqualTo(m.hashCode());
  }

  @Test
  public void testEqualsNullComparison() {
    Message m = new Message("Text", "Scope", "");
    assertThat(m).isNotEqualTo(null);

    m = new Message("", "", "");
    assertThat(m).isNotEqualTo(null);

    m = new Message("This is my smartphone", "smartphone", "");
    assertThat(m).isNotEqualTo(null);
  }

  @Test
  public void testHashCodeEqualsContract() {
    Message m = new Message("Text", "Scope", "");
    Message mm = new Message("Text", "Scope", "");
    assertThat(m.hashCode()).isEqualTo(mm.hashCode());
    assertThat(m).isEqualTo(mm);

    m = new Message("I am eating an apple", "apple", "");
    mm = new Message("I am EATING an APPLE", "APPLE", "");
    assertThat(m.hashCode()).isNotEqualTo(mm.hashCode());
    assertThat(m).isNotEqualTo(mm);
  }
}

@@ -104,59 +104,606 @@
 at;%0A
-%0Aimport org.junit.Test;%0A%0Apublic class MessageTest %7B
+import static org.assertj.core.api.Assertions.assertThatCode;%0A%0Aimport org.junit.Test;%0A%0Apublic class MessageTest %7B%0A%0A  @Test%0A  public void testNullConstructor() %7B%0A    assertThatCode(() -%3E new Message(null, %22null%22, %22value%22)).doesNotThrowAnyException();%0A%0A    assertThatCode(() -%3E new Message(null, null, %22value%22)).doesNotThrowAnyException();%0A%0A    assertThatCode(() -%3E new Message(null, null, null)).doesNotThrowAnyException();%0A%0A    Message m = new Message(null, null, null);%0A    assertThat(m.getMessage()).isEmpty();%0A    assertThat(m.getScope()).isEmpty();%0A    assertThat(m.getEmotion()).isEmpty();%0A  %7D
 %0A%0A  
@@ -1463,32 +1463,519 @@
 isEmpty();%0A  %7D%0A%0A
+  @Test%0A  public void testGetEmotion() %7B%0A    Message m  = new Message(%22I am a message with an emotion!%22, %22emotion%22, %22happy%22);%0A    assertThat(m.getEmotion()).isEqualTo(%22happy%22);%0A%0A    m = new Message(%22Just a little sad :(%22, %22sad%22, %22sad%22);%0A    assertThat(m.getEmotion()).isEqualTo(%22sad%22);%0A%0A    m = new Message(%22ANGRY, ANGRY!%22, %22:/%22, %22angry%22);%0A    assertThat(m.getEmotion()).isEqualTo(%22angry%22);%0A%0A    m = new Message(%22ANGRY, ANGRY!%22, %22:/%22, %22%22);%0A    assertThat(m.getEmotion()).isEmpty();%0A  %7D%0A%0A
   @Test%0A  public

improve MessageTest