I need to create an integration test against a REST API. My service is using Resttemplate as HTTP client. The client code is generated from swagger file.
Running the test yields an error java.lang.AssertionError: No further requests expected: HTTP GET
It seems that the test is running against a mock server. How to let the test run against the real server?
This is my current test setup (want to cut out a minimal test frame to get a fast test - booting the complete context is far too slow):
@RunWith(SpringRunner.class)
@Import(value = { TpzConfig.class, TpzServiceRestImpl.class, ManufacturingPlantPhPmMapperImpl.class,
ProductHierarchyMapperImpl.class, PlantMapperImpl.class })
@ActiveProfiles(profiles = { "tpz" })
@RestClientTest
public class TpzServiceRestImplTest {
@Autowired
private TpzService to;
@MockBean
private ProductionPlantService ppService;
@MockBean
private ProductHierarchyService phService;
@Test
public void test() {
List<ProductManufacturer> pmByProductHierarchy = to.pmByProductHierarchy("001100909100100388");
}
}
I need @RestClientTest
to have a bean of RestTemplateBuilder.
Is there a way to configure @RestClientTest
to use the real server (similar to @DataJpaTest
where i can configure not to use h2)?