View Javadoc

    1   package org.example.customerdao.utility;
    2
    3   import static org.junit.jupiter.api.Assertions.assertEquals;
    4   import static org.junit.jupiter.api.Assertions.assertNotNull;
    5
    6   import org.junit.jupiter.api.Test;
    7
    8   public class TestNonDeleteableRecordException
    9   {
    10      @Test
    11      public void testDefaultConstructor() {
    12
    13          NonDeleteableRecordException result = new NonDeleteableRecordException();
    14
    15          assertNotNull(result);
    16          assertEquals(null, result.getCause());
    17          assertEquals(
    18                  "org.example.customerdao.utility.NonDeleteableRecordException: " +
    19                  "Record is not deleteable", result.toString());
    20          assertEquals(
    21                  "Record is not deleteable", result.getMessage());
    22          assertEquals(
    23                  "Record is not deleteable", result.getLocalizedMessage());
    24      }
    25
    26      @Test
    27      public void testStringConstructor() {
    28
    29          String message = "Dummy Message";
    30
    31          NonDeleteableRecordException result =
    32                  new NonDeleteableRecordException(message);
    33
    34          assertNotNull(result);
    35          assertEquals(null, result.getCause());
    36          assertEquals(
    37             "org.example.customerdao.utility.NonDeleteableRecordException: " +
    38             "Dummy Message", result.toString());
    39          assertEquals("Dummy Message", result.getMessage());
    40          assertEquals("Dummy Message", result.getLocalizedMessage());
    41      }
    42
    43      @Test
    44      public void testThrowableConstructor() {
    45
    46          Throwable cause = new Throwable();
    47
    48          NonDeleteableRecordException result =
    49                  new NonDeleteableRecordException(cause);
    50
    51          assertNotNull(result);
    52          assertEquals(
    53             "org.example.customerdao.utility.NonDeleteableRecordException: " +
    54             "java.lang.Throwable", result.toString());
    55          assertEquals("java.lang.Throwable", result.getMessage());
    56          assertEquals("java.lang.Throwable", result.getLocalizedMessage());
    57      }
    58
    59      @Test
    60      public void testStringThrowableConstructor() {
    61
    62          String message = "Dummy Message";
    63          Throwable cause = new Throwable();
    64
    65          NonDeleteableRecordException result =
    66                  new NonDeleteableRecordException(message, cause);
    67
    68          assertNotNull(result);
    69          assertEquals(
    70             "org.example.customerdao.utility.NonDeleteableRecordException: " +
    71             "Dummy Message", result.toString());
    72          assertEquals("Dummy Message", result.getMessage());
    73          assertEquals("Dummy Message", result.getLocalizedMessage());
    74      }
    75  }