Skip to content

Instantly share code, notes, and snippets.

View alexandramartinez's full-sized avatar
🐱
Fighting w/my cat

Alex Martinez alexandramartinez

🐱
Fighting w/my cat
View GitHub Profile
@alexandramartinez
alexandramartinez / 01-DW-2.md
Last active May 28, 2020 14:41
DW 2.0 functions

DataWeave 2.0 Cheatsheet

Object Concatenation

(object-concatenation.dwl)

  • Using ++
  • Using {( )}
  • Using {([ ])}

String Concatenation

(string-concatenation.dwl)

#!/bin/bash
yum update -y
yum install -y httpd24 php56 mysql php56-mysqlnd
service httpd start
chkconfig httpd on
echo "fs-56fc251e.efs.us-east-1.amazonaws.com:/ /var/www/html nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 0 0" >> /etc/fstab
mount -a
var jsonData = pm.response.json();
pm.test("Content-Type is present", function () {
pm.response.to.have.header("Content-Type");
});
pm.test("Content-Type is application/json", function () {
pm.expect(postman.getResponseHeader("Content-Type")).to.include("application/json");
});
%dw 2.0
output application/json
var newObject = {
fieldC: "Field C Value"
}
var newObject2 = {
fieldD: "Field D Value",
object2: {
%dw 2.0
output application/json
var newObject = {
fieldC: "Field C Value"
}
var newObject2 = {
fieldD: "Field D Value",
object2: {
%dw 2.0
output application/json
var newObject = {
fieldC: "Field C Value"
}
var newObject2 = {
fieldD: "Field D Value",
object2: {
import java.util.Base64;
public class Base64UrlEncoding {
public static void main(String []args) {
byte[] bytes = "prostdev?blog".getBytes();
String encodedString = new String(Base64.getUrlEncoder().encode(bytes));
System.out.println(encodedString);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="14ccf972-4bba-4789-b1f2-0ce9b8dde24f" >
<http:listener-connection host="0.0.0.0" port="8081"
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:twilio-connector="http://www.mulesoft.org/schema/mule/twilio-connector"
xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
<!-- Solace -->
<dependency>
<groupId>com.solacesystems</groupId>
<artifactId>sol-jcsmp</artifactId>
<version>10.2.0</version>
</dependency>
<dependency>
<groupId>com.solacesystems</groupId>
<artifactId>sol-jms</artifactId>
<version>10.3.0</version>