Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
fix catalog test
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoDiGiuseppe committed Jan 27, 2023
1 parent 500f00e commit 2df5e7a
Showing 1 changed file with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
*/
package org.activiti.cloud.examples;

import static org.assertj.core.api.Assertions.assertThat;

import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import org.activiti.cloud.examples.connectors.*;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -29,11 +26,18 @@
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.TestPropertySource;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = { CloudConnectorApp.class })
import java.io.IOException;

import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.cloud.function.context.FunctionRegistration.REGISTRATION_NAME_SUFFIX;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = {CloudConnectorApp.class})
@AutoConfigureMockMvc
@TestPropertySource(locations = "classpath:application.properties")
public class CloudConnectorAppIT {

private final static String CONNECTOR_SUFFIX = "Connector";

@Autowired
private ApplicationContext context;

Expand All @@ -57,19 +61,21 @@ public void contextShouldLoad() throws Exception {

@Test
public void functionCatalogContainsFunctionDefinitions() {
assertThat(functionCatalog.<Object>lookup(ExampleConnectorChannels.EXAMPLE_CONNECTOR_CONSUMER + "Connector"))
assertThat(functionCatalog.<Object>lookup(getRegisteredConnectorName(ExampleConnectorChannels.EXAMPLE_CONNECTOR_CONSUMER)))
.isNotNull();
assertThat(functionCatalog.<Object>lookup(HeadersConnectorChannels.HEADERS_CONNECTOR_CONSUMER + "Connector"))
assertThat(functionCatalog.<Object>lookup(getRegisteredConnectorName(HeadersConnectorChannels.HEADERS_CONNECTOR_CONSUMER)))
.isNotNull();
assertThat(functionCatalog.<Object>lookup(HeadersConnectorChannels.HEADERS_CONNECTOR_CONSUMER + "Connector"))
assertThat(functionCatalog.<Object>lookup(getRegisteredConnectorName(HeadersConnectorChannels.HEADERS_CONNECTOR_CONSUMER)))
.isNotNull();
assertThat(
functionCatalog.<Object>lookup(MoviesDescriptionConnectorChannels.MOVIES_DESCRIPTION_CONSUMER + "Connector")
)
functionCatalog.<Object>lookup(getRegisteredConnectorName(MoviesDescriptionConnectorChannels.MOVIES_DESCRIPTION_CONSUMER)))
.isNotNull();
assertThat(functionCatalog.<Object>lookup(getRegisteredConnectorName(MultiInstanceConnector.Channels.CHANNEL)))
.isNotNull();
assertThat(functionCatalog.<Object>lookup(getRegisteredConnectorName(TestBpmnErrorConnector.Channels.CHANNEL)))
.isNotNull();
assertThat(functionCatalog.<Object>lookup(getRegisteredConnectorName(TestErrorConnector.Channels.CHANNEL)))
.isNotNull();
assertThat(functionCatalog.<Object>lookup(MultiInstanceConnector.Channels.CHANNEL + "Connector")).isNotNull();
assertThat(functionCatalog.<Object>lookup(TestBpmnErrorConnector.Channels.CHANNEL + "Connector")).isNotNull();
assertThat(functionCatalog.<Object>lookup(TestErrorConnector.Channels.CHANNEL + "Connector")).isNotNull();
}

@Test
Expand All @@ -79,4 +85,8 @@ public void shouldConvertExpectedJsonToPojo() throws IOException {
CustomPojo customPojo = objectMapper.convertValue(jsonValue, CustomPojo.class);
assertThat(customPojo).isNotNull();
}

private static String getRegisteredConnectorName(String functionName) {
return functionName + CONNECTOR_SUFFIX + REGISTRATION_NAME_SUFFIX;
}
}

0 comments on commit 2df5e7a

Please sign in to comment.