Commit 2c79e2b3 authored by Smitha Manjunath's avatar Smitha Manjunath
Browse files

clean up extra lines.

parent 65979763
package org.opengroup.osdu.azure.health;
import org.opengroup.osdu.azure.logging.CoreLoggerFactory;
import org.springframework.boot.actuate.endpoint.SecurityContext;
import org.springframework.boot.actuate.endpoint.http.ApiVersion;
......@@ -26,22 +23,16 @@ public class ActuatorHealthLogger extends HealthEndpointWebExtension {
private static final String LOGGER_NAME = ActuatorHealthLogger.class.getName();
/**
*
* @param registry the HealthContributorRegistry
* @param groups the HealthEndpointGroups
* @param groups the HealthEndpointGroups
*/
public ActuatorHealthLogger(final HealthContributorRegistry registry, final HealthEndpointGroups groups) {
super(registry, groups);
}
}
/**
*
* @param apiVersion
* @param securityContext
* @param showAll
......@@ -69,19 +60,15 @@ public class ActuatorHealthLogger extends HealthEndpointWebExtension {
}
}
return response;
}
/**
*
* @param apiVersion the Api Version
* @param apiVersion the Api Version
* @param securityContext the security Context
* @param showAll the boolean flag
* @param path the path
* @param showAll the boolean flag
* @param path the path
* @return the webEndpointResponse object
*
* */
*/
protected WebEndpointResponse<HealthComponent> superClassCall(final ApiVersion apiVersion, final SecurityContext securityContext, final boolean showAll, final String... path) {
return super.health(apiVersion, securityContext, showAll, path);
}
......
package org.opengroup.osdu.azure.health;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
......@@ -27,12 +26,10 @@ import java.util.Map;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* Tests for LoggingHealthEndPointWebExtension.
*/
......@@ -43,7 +40,6 @@ public class ActuatorHealthLoggerTest {
private static HealthContributorRegistry registry;
private static HealthEndpointGroups groups;
@Mock
private CoreLoggerFactory coreLoggerFactory;
......@@ -66,13 +62,12 @@ public class ActuatorHealthLoggerTest {
}
@BeforeEach
public void setup() {
public void setup() {
registry = mock(HealthContributorRegistry.class);
groups = mock(HealthEndpointGroups.class);
}
@Mock
SecurityContext securityContext;
......@@ -83,87 +78,51 @@ public class ActuatorHealthLoggerTest {
CompositeHealth compositeHealth;
@Test
public void healthTest_whenStatusIs_DOWN()
{
public void healthTest_whenStatusIs_DOWN() {
String[] path = new String[0];
mockSingleton(coreLoggerFactory);
when(coreLoggerFactory.getLogger(anyString())).thenReturn(logger);
Mockito.when(health.getStatus()).thenReturn(Status.DOWN);
Map<String, HealthComponent> map = new HashMap<>();
map.put("keyvault",health);
map.put("keyvault", health);
Mockito.when(compositeHealth.getComponents()).thenReturn(map);
WebEndpointResponse<HealthComponent> expected = new WebEndpointResponse<>(compositeHealth,WebEndpointResponse.STATUS_SERVICE_UNAVAILABLE);
WebEndpointResponse<HealthComponent> expected = new WebEndpointResponse<>(compositeHealth, WebEndpointResponse.STATUS_SERVICE_UNAVAILABLE);
loggingHealthEndpointWebExtension = new ActuatorHealthLogger(registry, groups) {
@Override
protected WebEndpointResponse<HealthComponent> superClassCall(ApiVersion apiVersion,SecurityContext securityContext,
protected WebEndpointResponse<HealthComponent> superClassCall(ApiVersion apiVersion, SecurityContext securityContext,
boolean showAll, String... path) {
return expected;
}
};
WebEndpointResponse<HealthComponent> actual = loggingHealthEndpointWebExtension.health(ApiVersion.LATEST, securityContext, true, path);
WebEndpointResponse<HealthComponent> actual = loggingHealthEndpointWebExtension.health(ApiVersion.LATEST,securityContext,true, path);
verify(logger, times(1)).error(anyString() , any() ,any());
verify(logger, times(1)).error(anyString(), any(), any());
}
@Test
public void healthTest_whenStatusIs_UP()
{
public void healthTest_whenStatusIs_UP() {
String[] path = new String[0];
Mockito.when(health.getStatus()).thenReturn(Status.UP);
Map<String, HealthComponent> map = new HashMap<>();
map.put("keyvault",health);
map.put("keyvault", health);
Mockito.when(compositeHealth.getComponents()).thenReturn(map);
WebEndpointResponse<HealthComponent> expected = new WebEndpointResponse<>(compositeHealth,WebEndpointResponse.STATUS_SERVICE_UNAVAILABLE);
WebEndpointResponse<HealthComponent> expected = new WebEndpointResponse<>(compositeHealth, WebEndpointResponse.STATUS_SERVICE_UNAVAILABLE);
loggingHealthEndpointWebExtension = new ActuatorHealthLogger(registry, groups) {
@Override
protected WebEndpointResponse<HealthComponent> superClassCall(ApiVersion apiVersion,SecurityContext securityContext,
protected WebEndpointResponse<HealthComponent> superClassCall(ApiVersion apiVersion, SecurityContext securityContext,
boolean showAll, String... path) {
return expected;
}
};
WebEndpointResponse<HealthComponent> actual = loggingHealthEndpointWebExtension.health(ApiVersion.LATEST,securityContext,true, path);
verify(logger, times(0)).error(anyString() , any() ,any());
WebEndpointResponse<HealthComponent> actual = loggingHealthEndpointWebExtension.health(ApiVersion.LATEST, securityContext, true, path);
verify(logger, times(0)).error(anyString(), any(), any());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment