Search in sources :

Example 6 with KnockeableDoor

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

the class AbstractHeisenbergConfigTestCase method getStartUpRegistryObjects.

@Override
protected Map<String, Object> getStartUpRegistryObjects() {
    final Map<String, Object> objects = new HashMap<>();
    objects.put("recipes", ImmutableMap.<String, Long>builder().put("methylamine", 75l).put("pseudoephedrine", 0l).put("P2P", 25l).build());
    objects.put("deathsBySeasons", ImmutableMap.<String, List<String>>builder().put("s01", ImmutableList.<String>builder().add("emilio").add("domingo").build()).put("s02", ImmutableList.<String>builder().add("tuco").add("tortuga").build()).build());
    Ricin ricin = new Ricin(new KnockeableDoor("Lidia", "Stevia coffe shop"), 22L);
    objects.put("labeledRicins", ImmutableMap.<String, Ricin>builder().put("pojo", ricin).build());
    objects.put("monthlyIncomes", ImmutableList.<Long>builder().add(12000L).add(500L).build());
    objects.put("enemies", ImmutableList.<String>builder().add("Gustavo Fring").add("Hank").build());
    objects.put("ricinPacks", ImmutableSet.<Ricin>builder().add(ricin).build());
    objects.put("candidateDoors", ImmutableMap.<String, KnockeableDoor>builder().put("skyler", new KnockeableDoor("Skyler", "308 Negra Arroyo Lane")).put("saul", new KnockeableDoor("Saul", "Shopping Mall")).build());
    return objects;
}
Also used : HashMap(java.util.HashMap) Ricin(org.mule.test.heisenberg.extension.model.Ricin) KnockeableDoor(org.mule.test.heisenberg.extension.model.KnockeableDoor) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList)

Example 7 with KnockeableDoor

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

the class OperationExecutionTestCase method operationWithExpressionListParameter.

@Test
public void operationWithExpressionListParameter() throws Exception {
    List<KnockeableDoor> doors = Arrays.asList(new KnockeableDoor("Skyler"), new KnockeableDoor("Saul"));
    List<String> response = (List<String>) flowRunner("knockManyByExpression").withPayload(EMPTY_STRING).withVariable("doors", doors).run().getMessage().getPayload().getValue();
    assertThat(response, Matchers.contains(knock("Skyler"), knock("Saul")));
}
Also used : KnockeableDoor(org.mule.test.heisenberg.extension.model.KnockeableDoor) List(java.util.List) ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 8 with KnockeableDoor

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

the class StackableTypesTestCase method configurationWithDynamicParameterResolvers.

@Test
public void configurationWithDynamicParameterResolvers() throws Exception {
    NestedWrapperTypesConfig config = getPayload("configurationWithDynamicParameterResolvers");
    ParameterResolver<TypedValue<KnockeableDoor>> doorResolver = config.getDoorResolver();
    TypedValue<KnockeableDoor> doorTypedValue = doorResolver.resolve();
    KnockeableDoor door = doorTypedValue.getValue();
    assertThat(door.getVictim(), is("Victim's Name"));
    ParameterResolver<TypedValue<InputStream>> lazyParameter = config.getLazyParameter();
    Optional<String> expression = lazyParameter.getExpression();
    TypedValue<InputStream> resolve = lazyParameter.resolve();
    InputStream value = resolve.getValue();
    String stringValue = IOUtils.toString(value);
    assertThat(expression, is(not(empty())));
    assertThat(expression.get(), is("#[output application/json --- {key : 'a nice looking json'}]"));
    assertThat(stringValue, is("{\n  \"key\": \"a nice looking json\"\n}"));
    ParameterResolver<ParameterResolver<ParameterResolver<ParameterResolver<TypedValue<InputStream>>>>> nestedParameter = config.getNestedParameter();
    TypedValue<InputStream> nestedTypedValue = nestedParameter.resolve().resolve().resolve().resolve();
    InputStream nestedValue = nestedTypedValue.getValue();
    String nestedString = IOUtils.toString(nestedValue);
    assertThat(nestedString, is("{\n  \"key\": \"pretty nested\"\n}"));
    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) ParameterResolver(org.mule.runtime.extension.api.runtime.parameter.ParameterResolver) InputStream(java.io.InputStream) 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)

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