Skip to content

Commit

Permalink
Merge pull request spring-projects#18557 from dreis2211
Browse files Browse the repository at this point in the history
* pr/18557:
  Polish
  Remove usage of @Injectmocks

Closes spring-projectsgh-18557
  • Loading branch information
snicoll committed Oct 12, 2019
2 parents 498ae64 + d8de6ff commit 53b0569
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
Expand Up @@ -16,11 +16,7 @@

package org.springframework.boot.actuate.integration;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import org.springframework.integration.graph.Graph;
import org.springframework.integration.graph.IntegrationGraphServer;
Expand All @@ -37,30 +33,23 @@
*/
class IntegrationGraphEndpointTests {

@Mock
private IntegrationGraphServer integrationGraphServer;
private final IntegrationGraphServer server = mock(IntegrationGraphServer.class);

@InjectMocks
private IntegrationGraphEndpoint integrationGraphEndpoint;

@BeforeEach
void setUp() {
MockitoAnnotations.initMocks(this);
}
private final IntegrationGraphEndpoint endpoint = new IntegrationGraphEndpoint(this.server);

@Test
void readOperationShouldReturnGraph() {
Graph mockedGraph = mock(Graph.class);
given(this.integrationGraphServer.getGraph()).willReturn(mockedGraph);
Graph graph = this.integrationGraphEndpoint.graph();
verify(this.integrationGraphServer).getGraph();
given(this.server.getGraph()).willReturn(mockedGraph);
Graph graph = this.endpoint.graph();
verify(this.server).getGraph();
assertThat(graph).isEqualTo(mockedGraph);
}

@Test
void writeOperationShouldRebuildGraph() {
this.integrationGraphEndpoint.rebuild();
verify(this.integrationGraphServer).rebuild();
this.endpoint.rebuild();
verify(this.server).rebuild();
}

}
2 changes: 1 addition & 1 deletion src/checkstyle/checkstyle.xml
Expand Up @@ -15,7 +15,7 @@
<property name="illegalPkgs"
value="^sun.*, ^org\.apache\.commons\.(?!compress|dbcp2|lang|lang3|logging|pool2).*, ^com\.google\.common.*, ^org\.flywaydb\.core\.internal.*, ^org\.testcontainers\.shaded.*" />
<property name="illegalClasses"
value="^com\.hazelcast\.util\.Base64, ^org\.junit\.rules\.ExpectedException, ^org\.slf4j\.LoggerFactory, ^reactor\.core\.support\.Assert" />
value="^com\.hazelcast\.util\.Base64, ^org\.junit\.rules\.ExpectedException, ^org\.mockito\.InjectMocks, ^org\.slf4j\.LoggerFactory, ^reactor\.core\.support\.Assert" />
</module>
<module
name="com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck">
Expand Down

0 comments on commit 53b0569

Please sign in to comment.