Search in sources :

Example 1 with ProcessEngineEndpoint

use of org.activiti.spring.boot.actuate.endpoint.ProcessEngineEndpoint in project Activiti by Activiti.

the class EndpointAutoConfigurationTest method mvcEndpoint.

@Test
public void mvcEndpoint() throws Throwable {
    AnnotationConfigEmbeddedWebApplicationContext applicationContext = new AnnotationConfigEmbeddedWebApplicationContext(CallbackEmbeddedContainerCustomizer.class, EmbeddedContainerConfiguration.class, EndpointConfiguration.class);
    ProcessEngine processEngine = applicationContext.getBean(ProcessEngine.class);
    org.junit.Assert.assertNotNull("the processEngine should not be null", processEngine);
    ProcessEngineEndpoint processEngineEndpoint = applicationContext.getBean(ProcessEngineEndpoint.class);
    org.junit.Assert.assertNotNull("the processEngineEndpoint should not be null", processEngineEndpoint);
    RestTemplate restTemplate = applicationContext.getBean(RestTemplate.class);
    ResponseEntity<Map> mapResponseEntity = restTemplate.getForEntity("http://localhost:9091/activiti/", Map.class);
    Map map = mapResponseEntity.getBody();
    String[] criticalKeys = { "completedTaskCount", "openTaskCount", "cachedProcessDefinitionCount" };
    Map<?, ?> invokedResults = processEngineEndpoint.invoke();
    for (String k : criticalKeys) {
        org.junit.Assert.assertTrue(map.containsKey(k));
        org.junit.Assert.assertEquals(((Number) map.get(k)).longValue(), ((Number) invokedResults.get(k)).longValue());
    }
}
Also used : RestTemplate(org.springframework.web.client.RestTemplate) ProcessEngineEndpoint(org.activiti.spring.boot.actuate.endpoint.ProcessEngineEndpoint) Map(java.util.Map) AnnotationConfigEmbeddedWebApplicationContext(org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext) ProcessEngine(org.activiti.engine.ProcessEngine) Test(org.junit.Test)

Aggregations

Map (java.util.Map)1 ProcessEngine (org.activiti.engine.ProcessEngine)1 ProcessEngineEndpoint (org.activiti.spring.boot.actuate.endpoint.ProcessEngineEndpoint)1 Test (org.junit.Test)1 AnnotationConfigEmbeddedWebApplicationContext (org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext)1 RestTemplate (org.springframework.web.client.RestTemplate)1