Skip to content

Commit

Permalink
Replace JUnit4 Assertions with Junit5 Jupiter Assertions
Browse files Browse the repository at this point in the history
updated test methods to junit-5
  • Loading branch information
Damans227 authored and manusa committed Dec 23, 2021
1 parent 16dc39c commit aacab40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import io.fabric8.kubernetes.client.utils.Serialization;
import io.fabric8.kubernetes.client.utils.URLUtils;
import io.fabric8.kubernetes.client.utils.Utils;
import okhttp3.OkHttpClient;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

Expand All @@ -56,10 +55,10 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -275,8 +274,7 @@ void testNoHttpRetryWithDefaultConfig() throws MalformedURLException, IOExceptio
});

// Then
assertTrue("As the first failure is an IOException the message of the causedBy expected to contain the given text: 'For example java.net.ConnectException'!",
exception.getCause().getMessage().contains("For example java.net.ConnectException"));
assertTrue(exception.getCause().getMessage().contains("For example java.net.ConnectException"), "As the first failure is an IOException the message of the causedBy expected to contain the given text: 'For example java.net.ConnectException'!");
assertEquals(1, httpExecutionCounter.get());
}

Expand All @@ -297,9 +295,8 @@ void testHttpRetryWithMoreFailuresThanRetries() throws MalformedURLException, IO
});

// Then
assertTrue("As the last failure, the 3rd one, is not an IOException the message expected to contain: 'Internal Server Error'!",
exception.getMessage().contains("Internal Server Error"));
assertEquals("Expected 4 calls: one normal try and 3 backoff retries!", 4, httpExecutionCounter.get());
assertTrue(exception.getMessage().contains("Internal Server Error"), "As the last failure, the 3rd one, is not an IOException the message expected to contain: 'Internal Server Error'!");
assertEquals(4, httpExecutionCounter.get(), "Expected 4 calls: one normal try and 3 backoff retries!");
}

@Test
Expand All @@ -318,7 +315,7 @@ void testHttpRetryWithLessFailuresThanRetries() throws MalformedURLException, IO

// Then
assertNotNull(result);
assertEquals("Expected 3 calls: 2 failures and 1 success!", 3, httpExecutionCounter.get());
assertEquals(3, httpExecutionCounter.get(), "Expected 3 calls: 2 failures and 1 success!");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

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

class ReflectorTest {

Expand Down

0 comments on commit aacab40

Please sign in to comment.