package de.bwaldvogel.mongo.oplog;

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

import java.util.UUID;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import de.bwaldvogel.mongo.bson.Document;

class OplogDocumentTest {

    OplogDocument oplogDocument;
    OplogDocument oplogDocument1;

    @BeforeEach
    public void setUp() {
        UUID uuid = UUID.randomUUID();
        oplogDocument = new OplogDocument().withOperationDocument(new Document())
            .withAdditionalOperationalDocument(new Document()).withT(123L).withHash(123L).withT(234L).withUUID(uuid);
        oplogDocument1 = new OplogDocument().withOperationDocument(new Document())
            .withAdditionalOperationalDocument(new Document()).withT(123L).withHash(123L).withT(234L).withUUID(uuid);
    }

    @Test
    void testEqualsNull() {
        assertThat(oplogDocument).isNotEqualTo(null);
    }

    @Test
    void testEqualsSameInstance() {
        assertThat(oplogDocument).isEqualTo(oplogDocument);
    }

    @Test
    void testEqualsDifferentType() {
        assertThat(oplogDocument).isNotEqualTo(new Object());
    }

    @Test
    void testEqualsUsingDocumentEquals() {
        assertThat(oplogDocument).isEqualTo(oplogDocument1);
    }

    @Test
    void testHashCode() {
        assertThat(oplogDocument.hashCode()).isEqualTo(oplogDocument.asDocument().hashCode());
    }
}

@@ -230,16 +230,101 @@
 ocument;
+%0Aimport nl.jqno.equalsverifier.EqualsVerifier;%0Aimport nl.jqno.equalsverifier.Warning;
 %0A%0Aclass 
@@ -344,24 +344,32 @@
 Test %7B%0A%0A    
+private 
 OplogDocumen
@@ -383,22 +383,31 @@
 Document
+1
 ;%0A    
+private 
 OplogDoc
@@ -425,17 +425,17 @@
 Document
-1
+2
 ;%0A%0A    @
@@ -453,15 +453,8 @@
     
-public 
 void
@@ -503,16 +503,17 @@
 UUID();%0A
+%0A
         
@@ -525,16 +525,17 @@
 Document
+1
  = new O
@@ -540,32 +540,45 @@
  OplogDocument()
+%0A            
 .withOperationDo
@@ -654,32 +654,45 @@
 (new Document())
+%0A            
 .withT(123L).wit
@@ -727,24 +727,25 @@
 UUID(uuid);%0A
+%0A
         oplo
@@ -745,33 +745,33 @@
    oplogDocument
-1
+2
  = new OplogDocu
@@ -776,16 +776,29 @@
 cument()
+%0A            
 .withOpe
@@ -890,16 +890,29 @@
 ument())
+%0A            
 .withT(1
@@ -1028,32 +1028,33 @@
 at(oplogDocument
+1
 ).isNotEqualTo(n
@@ -1136,32 +1136,33 @@
 at(oplogDocument
+1
 ).isEqualTo(oplo
@@ -1170,16 +1170,17 @@
 Document
+1
 );%0A    %7D
@@ -1256,24 +1256,25 @@
 plogDocument
+1
 ).isNotEqual
@@ -1383,16 +1383,17 @@
 Document
+1
 ).isEqua
@@ -1401,33 +1401,33 @@
 To(oplogDocument
-1
+2
 );%0A    %7D%0A%0A    @T
@@ -1447,16 +1447,22 @@
 test
+Equals
 HashCode
 () %7B
@@ -1461,103 +1461,328 @@
 Code
-() %7B%0A        assertThat(oplogDocument.hashCode()).isEqualTo(oplogDocument.asDocument().hashCode
+Contract() throws Exception %7B%0A        EqualsVerifier.forClass(OplogDocument.class)%0A            .suppress(Warning.STRICT_INHERITANCE)%0A            .withNonnullFields(%22document%22)%0A            .verify();%0A    %7D%0A%0A    @Test%0A    void testHashCode() %7B%0A        assertThat(oplogDocument1).hasSameHashCodeAs(oplogDocument1.asDocument
 ());
@@ -1788,10 +1788,11 @@
 ;%0A    %7D%0A
+%0A
 %7D%0A

Improve OplogDocumentTest