Search in sources :

Example 1 with KnockeableDoor

use of org.mule.test.heisenberg.extension.model.KnockeableDoor in project mule by mulesoft.

the class StackableTypesTestCase method configurationWithStaticParameterResolvers.

@Test
public void configurationWithStaticParameterResolvers() throws Exception {
    NestedWrapperTypesConfig config = getPayload("configurationWithStaticParameterResolvers");
    ParameterResolver<TypedValue<KnockeableDoor>> doorResolver = config.getDoorResolver();
    TypedValue<KnockeableDoor> doorTypedValue = doorResolver.resolve();
    KnockeableDoor door = doorTypedValue.getValue();
    assertThat(door.getVictim(), is("Victim's Name"));
    ParameterResolver<TypedValue<String>> lazyParameter = config.getLazyString();
    Optional<String> expression = lazyParameter.getExpression();
    TypedValue<String> resolve = lazyParameter.resolve();
    assertThat(expression, is(empty()));
    assertThat(resolve.getValue(), is("a nice looking string"));
    ParameterResolver<Literal<String>> resolverOfLiteral = config.getResolverOfLiteral();
    Literal<String> stringLiteral = resolverOfLiteral.resolve();
    Optional<String> literalValue = stringLiteral.getLiteralValue();
    assertThat(literalValue, is(not(empty())));
    assertThat(literalValue.get(), is("this doesn't make sense"));
}
Also used : NestedWrapperTypesConfig(org.mule.test.parameter.resolver.extension.extension.NestedWrapperTypesConfig) Literal(org.mule.runtime.extension.api.runtime.parameter.Literal) KnockeableDoor(org.mule.test.heisenberg.extension.model.KnockeableDoor) TypedValue(org.mule.runtime.api.metadata.TypedValue) Test(org.junit.Test)

Example 2 with KnockeableDoor

use of org.mule.test.heisenberg.extension.model.KnockeableDoor in project mule by mulesoft.

the class FunctionExecutionTestCase method executeWithTypedValueParameters.

@Test
public void executeWithTypedValueParameters() throws Exception {
    final String xmlString = IOUtils.toString(getDocumentStream());
    final InputStream jsonStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("models/subtypes.json");
    final KnockeableDoor knockeableDoor = new KnockeableDoor("Ricky", "Universe 137");
    TypedValue<List<Object>> payload = flowRunner("typedValueFunction").withPayload(new TypedValue<>(xmlString, XML_STRING)).withVariable("door", TypedValue.of(knockeableDoor)).withVariable("xmlString", new TypedValue<>(xmlString, XML_STRING)).withVariable("jsonStream", new TypedValue<>(jsonStream, DataType.builder().type(InputStream.class).mediaType(APPLICATION_JSON).build())).run().getMessage().getPayload();
    List<Object> values = payload.getValue();
    assertThat(values, hasSize(4));
    assertThat(getValue(values.get(0)), is(xmlString));
    assertThat(getValue(values.get(1)), is(xmlString));
    assertThat(getValue(values.get(2)), is(jsonStream));
    assertThat(getValue(values.get(3)), is(knockeableDoor));
}
Also used : InputStream(java.io.InputStream) KnockeableDoor(org.mule.test.heisenberg.extension.model.KnockeableDoor) NodeList(org.w3c.dom.NodeList) List(java.util.List) Matchers.containsString(org.hamcrest.Matchers.containsString) TypedValue(org.mule.runtime.api.metadata.TypedValue) Test(org.junit.Test)

Example 3 with KnockeableDoor

use of org.mule.test.heisenberg.extension.model.KnockeableDoor in project mule by mulesoft.

the class ParameterizedConfigParserTestCase method assertDoors.

private void assertDoors(HeisenbergExtension heisenberg) {
    KnockeableDoor door = heisenberg.getRicinGroup().getNextDoor();
    assertDoor(door, GUSTAVO_FRING, POLLOS_HERMANOS);
    KnockeableDoor previous = door.getPrevious();
    assertDoor(door.getPrevious(), KRAZY_8, JESSE_S);
    assertNull(previous.getPrevious());
}
Also used : KnockeableDoor(org.mule.test.heisenberg.extension.model.KnockeableDoor)

Example 4 with KnockeableDoor

use of org.mule.test.heisenberg.extension.model.KnockeableDoor in project mule by mulesoft.

the class ParameterResolverOnConfigTestCase method configurationWithDynamicParameterResolvers.

@Test
public void configurationWithDynamicParameterResolvers() throws Exception {
    ParameterResolverConfig config = getPayload("configurationWithDynamicParameterResolvers");
    ParameterResolver<KnockeableDoor> doorResolver = config.getDoorResolver();
    ParameterResolver<String> stringResolver = config.getStringResolver();
    assertParameterResolver(doorResolver, of("#[app.registry.staticDoor]"), is(instanceOf(KnockeableDoor.class)));
    assertParameterResolver(stringResolver, of("#[payload]"), is("this is the payload"));
    assertThat(config.getLiteralDoor().getLiteralValue().get(), equalTo("#[aDoor]"));
}
Also used : KnockeableDoor(org.mule.test.heisenberg.extension.model.KnockeableDoor) ParameterResolverConfig(org.mule.test.parameter.resolver.extension.extension.ParameterResolverConfig) Test(org.junit.Test)

Example 5 with KnockeableDoor

use of org.mule.test.heisenberg.extension.model.KnockeableDoor in project mule by mulesoft.

the class ParameterResolverOnConfigTestCase method configurationWithStaticParameterResolvers.

@Test
public void configurationWithStaticParameterResolvers() throws Exception {
    ParameterResolverConfig config = getPayload("configurationWithStaticParameterResolvers");
    ParameterResolver<KnockeableDoor> doorResolver = config.getDoorResolver();
    ParameterResolver<String> stringResolver = config.getStringResolver();
    assertParameterResolver(doorResolver, empty(), is(instanceOf(KnockeableDoor.class)));
    assertParameterResolver(stringResolver, empty(), is("this is a string"));
}
Also used : KnockeableDoor(org.mule.test.heisenberg.extension.model.KnockeableDoor) ParameterResolverConfig(org.mule.test.parameter.resolver.extension.extension.ParameterResolverConfig) Test(org.junit.Test)

Aggregations

KnockeableDoor (org.mule.test.heisenberg.extension.model.KnockeableDoor)8 Test (org.junit.Test)6 List (java.util.List)3 TypedValue (org.mule.runtime.api.metadata.TypedValue)3 InputStream (java.io.InputStream)2 Literal (org.mule.runtime.extension.api.runtime.parameter.Literal)2 NestedWrapperTypesConfig (org.mule.test.parameter.resolver.extension.extension.NestedWrapperTypesConfig)2 ParameterResolverConfig (org.mule.test.parameter.resolver.extension.extension.ParameterResolverConfig)2 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 ParameterResolver (org.mule.runtime.extension.api.runtime.parameter.ParameterResolver)1 Ricin (org.mule.test.heisenberg.extension.model.Ricin)1 NodeList (org.w3c.dom.NodeList)1