Explorar o código

DivorceCertificateService tests

Andrew Grant hai 1 mes
pai
achega
ebc41d5733

+ 0 - 68
src/test/java/scot/carricksoftware/grantswriter/services/certificates/divorcecertificate/DivorceCertificateDateTest.java

@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
- *
- */
-
-package scot.carricksoftware.grantswriter.services.certificates.divorcecertificate;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import scot.carricksoftware.grantswriter.domains.certificates.divorcecertificate.DivorceCertificate;
-
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static scot.carricksoftware.grantswriter.GenerateCertificateRandomValues.GetRandomString;
-
-
-class DivorceCertificateDateTest {
-
-    private DivorceCertificate certificate;
-
-    @BeforeEach
-    void setUp() {
-        certificate = new DivorceCertificate();
-    }
-
-    @Test
-    public void getFirstPartyDateTest() {
-        assertNull(certificate.getFirstPartyDate());
-    }
-
-    @Test
-    public void setFirstPartyDateTest() {
-        String string = GetRandomString();
-        certificate.setFirstPartyDate(string);
-        assertEquals(string, certificate.getFirstPartyDate());
-    }
-
-    @Test
-    public void getSecondPartyDateTest() {
-        assertNull(certificate.getSecondPartyDate());
-    }
-
-    @Test
-    public void setSecondPartyDateTest() {
-        String string = GetRandomString();
-        certificate.setSecondPartyDate(string);
-        assertEquals(string, certificate.getSecondPartyDate());
-    }
-
-    @Test
-    public void getRegisteredDateTest() {
-        assertNull(certificate.getRegisteredDate());
-    }
-
-    @Test
-    public void setRegisteredDateTest() {
-        String string = GetRandomString();
-        certificate.setRegisteredDate(string);
-        assertEquals(string, certificate.getRegisteredDate());
-    }
-
-
-
-
-
-
-}

+ 0 - 40
src/test/java/scot/carricksoftware/grantswriter/services/certificates/divorcecertificate/DivorceCertificateIDTest.java

@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
- *
- */
-
-package scot.carricksoftware.grantswriter.services.certificates.divorcecertificate;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import scot.carricksoftware.grantswriter.domains.certificates.divorcecertificate.DivorceCertificate;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static scot.carricksoftware.grantswriter.GenerateRandomNumberValues.GetRandomLong;
-
-
-class DivorceCertificateIDTest {
-
-    private DivorceCertificate certificate;
-
-    @BeforeEach
-    void setUp() {
-        certificate = new DivorceCertificate();
-    }
-
-    @Test
-    public void getIdTest() {
-        assertNull(certificate.getId());
-    }
-
-    @Test
-    public void setIdTest() {
-        Long id = GetRandomLong();
-        certificate.setId(id);
-        assertEquals(id, certificate.getId());
-    }
-
-
-
-}

+ 0 - 55
src/test/java/scot/carricksoftware/grantswriter/services/certificates/divorcecertificate/DivorceCertificatePeopleTest.java

@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
- *
- */
-
-package scot.carricksoftware.grantswriter.services.certificates.divorcecertificate;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import scot.carricksoftware.grantswriter.domains.certificates.divorcecertificate.DivorceCertificate;
-import scot.carricksoftware.grantswriter.domains.people.Person;
-
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static scot.carricksoftware.grantswriter.GenerateRandomPeopleValues.GetRandomPerson;
-
-
-class DivorceCertificatePeopleTest {
-
-    private DivorceCertificate certificate;
-
-    @BeforeEach
-    void setUp() {
-        certificate = new DivorceCertificate();
-    }
-
-    @Test
-    public void getFirstPartyTest() {
-        assertNull(certificate.getFirstParty());
-    }
-
-    @Test
-    public void setFirstPartyTest() {
-        Person person = GetRandomPerson();
-        certificate.setFirstParty(person);
-        assertEquals(person, certificate.getFirstParty());
-    }
-
-    @Test
-    public void getSecondPartyTest() {
-        assertNull(certificate.getSecondParty());
-    }
-
-    @Test
-    public void setSecondPartyTest() {
-        Person person = GetRandomPerson();
-        certificate.setSecondParty(person);
-        assertEquals(person, certificate.getSecondParty());
-    }
-
-
-
-
-}

+ 58 - 0
src/test/java/scot/carricksoftware/grantswriter/services/certificates/divorcecertificate/DivorceCertificateServiceTest.java

@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 27/03/2025, 01:24. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grantswriter.services.certificates.divorcecertificate;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import scot.carricksoftware.grantswriter.domains.certificates.divorcecertificate.DivorceCertificate;
+import scot.carricksoftware.grantswriter.domains.people.Person;
+import scot.carricksoftware.grantswriter.repositories.certificates.birthcertificate.DivorceCertificateRepository;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.when;
+import static scot.carricksoftware.grantswriter.GenerateRandomPeopleValues.GetRandomPerson;
+
+
+@ExtendWith(MockitoExtension.class)
+public class DivorceCertificateServiceTest {
+
+    DivorceCertificateService divorceCertificateService;
+
+    @Mock
+    DivorceCertificateRepository divorceCertificateRepositoryMock;
+
+    private Person person;
+
+    @BeforeEach
+    public void setUp() {
+        divorceCertificateService = new DivorceCertificateServiceImpl(divorceCertificateRepositoryMock);
+        person = GetRandomPerson();
+    }
+
+    @Test
+    public void findAllByFirstPartyTest() {
+        List<DivorceCertificate> certificates = new ArrayList<>();
+        certificates.add(new DivorceCertificate());
+        when(divorceCertificateRepositoryMock.findAllByFirstParty(person)).thenReturn(certificates);
+        assertEquals(certificates, divorceCertificateService.findAllByFirstParty(person));
+    }
+
+    @Test
+    public void findAllBySecondPartyTest() {
+        List<DivorceCertificate> certificates = new ArrayList<>();
+        certificates.add(new DivorceCertificate());
+        when(divorceCertificateRepositoryMock.findAllBySecondParty(person)).thenReturn(certificates);
+        assertEquals(certificates, divorceCertificateService.findAllBySecondParty(person));
+    }
+
+}