nitpicks (#1197)
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
package org.springframework.cloud.kubernetes.commons;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -27,21 +25,18 @@ import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Ryan Baxter
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE,
|
||||
classes = KubernetesCommonsAutoConfigurationTests.App.class,
|
||||
properties = { "spring.main.cloud-platform=KUBERNETES", "spring.cloud.kubernetes.client.password=mypassword",
|
||||
"spring.cloud.kubernetes.client.proxy-password=myproxypassword" })
|
||||
public class KubernetesCommonsAutoConfigurationTests {
|
||||
class KubernetesCommonsAutoConfigurationTests {
|
||||
|
||||
@Autowired
|
||||
ConfigurableApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void beansAreCreated() {
|
||||
void beansAreCreated() {
|
||||
assertThat(context.getBeansOfType(KubernetesClientProperties.class)).hasSize(1);
|
||||
|
||||
KubernetesClientProperties properties = context.getBeansOfType(KubernetesClientProperties.class).values()
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.kubernetes.commons;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
@@ -34,24 +33,24 @@ import static org.springframework.cloud.kubernetes.commons.KubernetesNamespacePr
|
||||
/**
|
||||
* @author Ryan Baxter
|
||||
*/
|
||||
public class KubernetesNamespaceProviderTests {
|
||||
class KubernetesNamespaceProviderTests {
|
||||
|
||||
private static final String PATH = "/some/path";
|
||||
|
||||
private MockedStatic<Paths> paths;
|
||||
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
void before() {
|
||||
paths = Mockito.mockStatic(Paths.class);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void after() {
|
||||
void after() {
|
||||
paths.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getNamespace() {
|
||||
void getNamespace() {
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
environment.setProperty(NAMESPACE_PROPERTY, "mynamespace");
|
||||
KubernetesNamespaceProvider p1 = new KubernetesNamespaceProvider(environment);
|
||||
@@ -60,16 +59,4 @@ public class KubernetesNamespaceProviderTests {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 1) serviceAccountNamespace File is present or not
|
||||
* 2) if the above is present, under what actualPath
|
||||
* </pre>
|
||||
*/
|
||||
private Path serviceAccountFileResolved(boolean present, String actualPath) {
|
||||
Path path = Mockito.mock(Path.class);
|
||||
paths.when(() -> Paths.get(actualPath)).thenReturn(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import static org.mockito.Mockito.verifyNoInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class LazilyInstantiateTest {
|
||||
class LazilyInstantiateTest {
|
||||
|
||||
private static final String TAG = "excluded-from-before";
|
||||
|
||||
@@ -52,28 +52,22 @@ public class LazilyInstantiateTest {
|
||||
|
||||
@Tag(TAG)
|
||||
@Test
|
||||
public void supplierNotCalledInLazyInstantiateFactoryMethod() {
|
||||
void supplierNotCalledInLazyInstantiateFactoryMethod() {
|
||||
LazilyInstantiate.using(this.mockSupplier);
|
||||
|
||||
// verify
|
||||
verifyNoInteractions(this.mockSupplier);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void factoryReturnsSingletonFromSupplier() {
|
||||
void factoryReturnsSingletonFromSupplier() {
|
||||
LazilyInstantiate<String> lazyStringFactory = LazilyInstantiate.using(this.mockSupplier);
|
||||
String singletonString = lazyStringFactory.get();
|
||||
|
||||
// verify
|
||||
assertThat(singletonString).isEqualTo(SINGLETON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void factoryOnlyCallsSupplierOnce() {
|
||||
void factoryOnlyCallsSupplierOnce() {
|
||||
LazilyInstantiate<String> lazyStringFactory = LazilyInstantiate.using(this.mockSupplier);
|
||||
lazyStringFactory.get();
|
||||
|
||||
// mock will throw exception if it is called more than once
|
||||
lazyStringFactory.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = App.class,
|
||||
properties = { "spring.cloud.kubernetes.config.fail-fast=true",
|
||||
"spring.cloud.kubernetes.secrets.fail-fast=true", "spring.main.cloud-platform=KUBERNETES" })
|
||||
public class ConfigAndSecretsFailFastEnabledWithDefaultRetryConfiguration {
|
||||
class ConfigAndSecretsFailFastEnabledWithDefaultRetryConfiguration {
|
||||
|
||||
@Autowired
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
Reference in New Issue
Block a user