Skip to content

Commit

Permalink
refactor: migration tests in credentials module from JUnit4 to JUnit5 (
Browse files Browse the repository at this point in the history
  • Loading branch information
Captain1653 committed Oct 8, 2021
1 parent cccaa44 commit a64d35c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
23 changes: 11 additions & 12 deletions credentials/javatests/com/google/auth/SigningExceptionTest.java
Expand Up @@ -31,45 +31,44 @@

package com.google.auth;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.google.auth.ServiceAccountSigner.SigningException;
import java.io.IOException;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class SigningExceptionTest {
class SigningExceptionTest {

private static final String EXPECTED_MESSAGE = "message";
private static final RuntimeException EXPECTED_CAUSE = new RuntimeException();

@Test
public void constructor() {
void constructor() {
SigningException signingException = new SigningException(EXPECTED_MESSAGE, EXPECTED_CAUSE);
assertEquals(EXPECTED_MESSAGE, signingException.getMessage());
assertSame(EXPECTED_CAUSE, signingException.getCause());
}

@Test
public void equals_true() throws IOException {
void equals_true() {
SigningException signingException = new SigningException(EXPECTED_MESSAGE, EXPECTED_CAUSE);
SigningException otherSigningException = new SigningException(EXPECTED_MESSAGE, EXPECTED_CAUSE);
assertTrue(signingException.equals(otherSigningException));
assertTrue(otherSigningException.equals(signingException));
}

@Test
public void equals_false_message() throws IOException {
void equals_false_message() {
SigningException signingException = new SigningException(EXPECTED_MESSAGE, EXPECTED_CAUSE);
SigningException otherSigningException = new SigningException("otherMessage", EXPECTED_CAUSE);
assertFalse(signingException.equals(otherSigningException));
assertFalse(otherSigningException.equals(signingException));
}

@Test
public void equals_false_cause() throws IOException {
void equals_false_cause() {
SigningException signingException = new SigningException(EXPECTED_MESSAGE, EXPECTED_CAUSE);
SigningException otherSigningException =
new SigningException("otherMessage", new RuntimeException());
Expand All @@ -78,7 +77,7 @@ public void equals_false_cause() throws IOException {
}

@Test
public void hashCode_equals() throws IOException {
void hashCode_equals() {
SigningException signingException = new SigningException(EXPECTED_MESSAGE, EXPECTED_CAUSE);
SigningException otherSigningException = new SigningException(EXPECTED_MESSAGE, EXPECTED_CAUSE);
assertEquals(signingException.hashCode(), otherSigningException.hashCode());
Expand Down
4 changes: 2 additions & 2 deletions credentials/pom.xml
Expand Up @@ -50,8 +50,8 @@

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down

0 comments on commit a64d35c

Please sign in to comment.