
Research
/Security News
Mini Shai-Hulud Campaign Hits Red Hat Cloud Services npm Packages
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.
de.codecentric.mule.modules:data-weave-caller
Advanced tools
Library to call DataWeave from Java and execute DW unit tests.
This project allows to run DataWeave code from Java. Additionally, you can write DataWeave unit tests and execute them like JUnit tests with the JUnit runner of your choice.
You can find the documentation for DataWeave unit tests at MuleSoft: DataWeave testing framework. There is additional documentation for the available DataWeave asserts.
First you need some dependencies in your pom.xml:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.13.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.13.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.codecentric.mule.modules</groupId>
<artifactId>data-weave-caller</artifactId>
<version>1.2.0</version>
<scope>test</scope>
</dependency>
To run your tests, you need a small Java adapter class:
package de.codecentric.dataweave;
import java.util.Collection;
import org.junit.jupiter.api.DynamicNode;
import org.junit.jupiter.api.TestFactory;
import de.codecentric.dwcaller.test.DataWeaveTests;
public class CallDataWeaveTests extends DataWeaveTests {
@TestFactory
Collection<DynamicNode> dataWeaveTests() throws Exception {
return some("src/test/resources/dataweave");
}
}
Place it in src/test/java.
Functions which you want to use in your Mule application (and for which you want to write tests) can be placed in src/main/resources/dataweave, e.g. in a file MyFunctions.dwl:
fun sayHello(): String = (
"Hello world!"
)
fun duplicate(s: String): String = (
s ++ s
)
fun extractNode(o: Object): Any = (
o.node
)
The unit test is placed in src/test/resources/dataweave/DataWeaveTests.dwl:
%dw 2.0
import * from dw::test::Tests
import * from dw::test::Asserts
import * from dataweave::MyFunctions
---
"my-functions" describedBy [
"say-hello" in do {
sayHello()
must equalTo("Hello world!")
},
"duplicate-string" in do {
duplicate("abc")
must equalTo("abcabc")
},
"extract-node" in do {
extractNode(readUrl("classpath://testdata/input-data.json", "application/json"))
must equalTo(readUrl("classpath://testdata/expected-result.json", "application/json"))
}
]
The referenced sample data in src/test/resources/sample_data
To execute the tests, run the class CallDataWeaveTests with the test runner of your choice (e.g. in your IDE).
Ignore non existing directors in synchronize (instead of throwing Exception)
Add root objects, so access to vars etc. does not create compile error
Adding dwtestResources property when not set, points to src/test/resources
Adding src/test/dw to folders which will by synchronized into target
Initial release
FAQs
Library to call DataWeave from Java and execute DW unit tests.
We found that de.codecentric.mule.modules:data-weave-caller demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.

Security News
The Rust project is moving toward formal rules on LLM use in contributions after months of internal debate over maintainer burden, code quality, and contributor experience.