Search in sources :

Example 1 with OperationParameters

use of org.mule.runtime.extension.api.client.OperationParameters in project mule by mulesoft.

the class ExtensionsClientTestCase method executeOperationWithNullSafeParameter.

@Test
@Description("Executes an operation that has a @NullSafe annotated parameter using the client and checks the output")
public void executeOperationWithNullSafeParameter() throws Throwable {
    OperationParameters params = builder().configName("banana").build();
    Result<VeganPolicy, Object> result = doExecute(VEGAN, "applyPolicy", params);
    assertThat(result.getOutput().getMeetAllowed(), is(false));
    assertThat(result.getOutput().getIngredients().getSaltMiligrams(), is(0));
}
Also used : OperationParameters(org.mule.runtime.extension.api.client.OperationParameters) VeganPolicy(org.mule.test.vegan.extension.VeganPolicy) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 2 with OperationParameters

use of org.mule.runtime.extension.api.client.OperationParameters in project mule by mulesoft.

the class ExtensionsClientTestCase method executeOperationThatReturnsAttributes.

@Test
@Description("Executes an operation that returns attributes metadata using the client and checks the output and the attributes")
public void executeOperationThatReturnsAttributes() throws Throwable {
    OperationParameters params = builder().configName(HEISENBERG_CONFIG).build();
    Result<String, IntegerAttributes> result = doExecute(HEISENBERG_EXT_NAME, "getEnemy", params);
    assertThat(result.getOutput(), is("Gustavo Fring"));
    assertThat(result.getAttributes().isPresent(), is(true));
    assertThat(result.getAttributes().get().getValue(), is(0));
}
Also used : OperationParameters(org.mule.runtime.extension.api.client.OperationParameters) IntegerAttributes(org.mule.test.heisenberg.extension.model.types.IntegerAttributes) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 3 with OperationParameters

use of org.mule.runtime.extension.api.client.OperationParameters in project mule by mulesoft.

the class ExtensionsClientTestCase method executeSimpleOperationWithExpression.

@Test
@Description("Executes a simple operation with an expression as parameter using the client and checks the output")
public void executeSimpleOperationWithExpression() throws Throwable {
    OperationParameters params = builder().configName(HEISENBERG_CONFIG).addParameter("victim", "#[mel:'Juani']").addParameter("goodbyeMessage", "ADIOS").build();
    Result<String, Object> result = doExecute(HEISENBERG_EXT_NAME, "kill", params);
    assertThat(result.getOutput(), is("ADIOS, Juani"));
}
Also used : OperationParameters(org.mule.runtime.extension.api.client.OperationParameters) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 4 with OperationParameters

use of org.mule.runtime.extension.api.client.OperationParameters in project mule by mulesoft.

the class ExtensionsClientTestCase method executeFailureOperation.

@Test
@Description("Executes an operation that fails using the client and checks the throwed exception")
public void executeFailureOperation() throws Throwable {
    exception.expect(MuleException.class);
    exception.expectCause(instanceOf(ConnectionException.class));
    exception.expectMessage("You are not allowed to speak with gus.");
    OperationParameters params = builder().configName(HEISENBERG_CONFIG).build();
    doExecute(HEISENBERG_EXT_NAME, "callGusFring", params);
}
Also used : OperationParameters(org.mule.runtime.extension.api.client.OperationParameters) ConnectionException(org.mule.runtime.api.connection.ConnectionException) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 5 with OperationParameters

use of org.mule.runtime.extension.api.client.OperationParameters in project mule by mulesoft.

the class ExtensionsClientTestCase method executeVoidOperation.

@Test
@Description("Executes a void operation using the client")
public void executeVoidOperation() throws Throwable {
    OperationParameters params = builder().configName(HEISENBERG_CONFIG).build();
    Result<Object, Object> result = doExecute(HEISENBERG_EXT_NAME, "die", params);
    assertThat(result.getOutput(), is(nullValue()));
    assertThat(result.getAttributes().isPresent(), is(false));
}
Also used : OperationParameters(org.mule.runtime.extension.api.client.OperationParameters) Description(io.qameta.allure.Description) Test(org.junit.Test)

Aggregations

Description (io.qameta.allure.Description)12 Test (org.junit.Test)12 OperationParameters (org.mule.runtime.extension.api.client.OperationParameters)12 Collection (java.util.Collection)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1 ConnectionException (org.mule.runtime.api.connection.ConnectionException)1 KnockeableDoor (org.mule.test.heisenberg.extension.model.KnockeableDoor)1 Ricin (org.mule.test.heisenberg.extension.model.Ricin)1 Weapon (org.mule.test.heisenberg.extension.model.Weapon)1 IntegerAttributes (org.mule.test.heisenberg.extension.model.types.IntegerAttributes)1 VeganPolicy (org.mule.test.vegan.extension.VeganPolicy)1