package de.invidit.design.creational.prototype;

import org.assertj.core.api.Assertions;
import org.junit.Test;

import java.util.ArrayList;

/**
 * @author Torsten Mingers
 */
public class ConversationInterviewTest {

    @Test
    public void testCloneCreatesCopy() {
        Conversation sut = createConversationInterview();

        ConversationInterview actual = (ConversationInterview) sut.clone();

        ConversationInterview sutInterview = (ConversationInterview)sut;
        Assertions.assertThat(actual.title).isEqualTo(sutInterview.title);
        Assertions.assertThat(actual.conversationItems).containsAll(sutInterview.conversationItems);
        Assertions.assertThat(actual).isNotSameAs(sut);
    }

    private Conversation createConversationInterview() {
        ConversationInterview conversation = new ConversationInterview();

        conversation.title = "Title";
        conversation.conversationItems = new ArrayList<ConversationItem>();
        conversation.conversationItems.add(new ConversationItem("Item 1"));
        conversation.conversationItems.add(new ConversationItem("Item 2"));
        conversation.conversationItems.add(new ConversationItem("Item 3"));
        conversation.conversationItems.add(new ConversationItem("Item 4"));

        return conversation;
    }
}
@@ -258,21 +258,36 @@
 atesCopy
+AndTitelIsEqual
 () %7B%0A
-
         
@@ -570,103 +570,677 @@
     
-    Assertions.assertThat(actual.conversationItems).containsAll(sutInterview.conversationItems)
+%7D%0A%0A    @Test%0A    public void testCloneCreatesCopyAndContainsSubitems() %7B%0A        Conversation sut = createConversationInterview();%0A%0A        ConversationInterview actual = (ConversationInterview) sut.clone();%0A%0A        ConversationInterview sutInterview = (ConversationInterview)sut;%0A        Assertions.assertThat(actual.conversationItems).containsAll(sutInterview.conversationItems);%0A    %7D%0A%0A    @Test%0A    public void testCloneCreatesCopyAndIsNotTheSameObject() %7B%0A        Conversation sut = createConversationInterview();%0A%0A        ConversationInterview actual = (ConversationInterview) sut.clone();%0A%0A        ConversationInterview sutInterview = (ConversationInterview)sut
 ;%0A  

Split tests