added back in 2 tests that were left out: testAppraiserNullName and testSetNameNull; will need main code fix to get tests to work

This commit is contained in:
iadgovuser58 2023-12-15 09:51:16 -05:00
parent a51dd5f7df
commit 7e749c49ab

View File

@ -1,7 +1,11 @@
package hirs.attestationca.persist.entity;
import hirs.attestationca.persist.entity.userdefined.certificate.CertificateAuthorityCredential;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.security.cert.CertificateException;
import static org.junit.jupiter.api.Assertions.*;
/**
@ -18,6 +22,16 @@ public final class AppraiserTest {
new TestAppraiser(name);
}
/**
* Tests that <code>Appraiser</code> throws a <code>NullPointerException</code> if a name is not
* provided.
*/
@Test
public void testAppraiserNullName() {
assertThrows(NullPointerException.class, () ->
new TestAppraiser(null));
}
/**
* Tests that the name is returned from <code>getName</code>.
*/
@ -41,6 +55,24 @@ public final class AppraiserTest {
assertEquals(newName, appraiser.getName());
}
/**
* Tests that a <code>NullPointerException</code> is thrown if the name is null.
*/
@Test
public void testSetNameNull() {
final String name = "Test Appraiser";
final Appraiser appraiser = new TestAppraiser(name);
assertEquals(name, appraiser.getName());
NullPointerException expected = null;
try {
appraiser.setName(null);
} catch (NullPointerException e) {
expected = e;
}
assertNotNull(expected, "NullPointerException not caught");
assertEquals(name, appraiser.getName());
}
/**
* Tests that x.equals(null) returns false.
*/