Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Danijel Dragicevic
assert-object-equals-module
Commits
4d7b57b0
Commit
4d7b57b0
authored
Mar 22, 2019
by
Danijel Dragicevic
Browse files
Initial commit.
parents
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
253 additions
and
0 deletions
+253
-0
README.md
README.md
+19
-0
pom.xml
pom.xml
+19
-0
src/main/java/de/codecentric/mule/modules/assertobjectequals/internal/AssertObjectEqualsConfiguration.java
...bjectequals/internal/AssertObjectEqualsConfiguration.java
+21
-0
src/main/java/de/codecentric/mule/modules/assertobjectequals/internal/AssertObjectEqualsConnection.java
...rtobjectequals/internal/AssertObjectEqualsConnection.java
+22
-0
src/main/java/de/codecentric/mule/modules/assertobjectequals/internal/AssertObjectEqualsConnectionProvider.java
...equals/internal/AssertObjectEqualsConnectionProvider.java
+63
-0
src/main/java/de/codecentric/mule/modules/assertobjectequals/internal/AssertObjectEqualsExtension.java
...ertobjectequals/internal/AssertObjectEqualsExtension.java
+17
-0
src/main/java/de/codecentric/mule/modules/assertobjectequals/internal/AssertObjectEqualsOperations.java
...rtobjectequals/internal/AssertObjectEqualsOperations.java
+37
-0
src/test/java/de/codecentric/mule/modules/assertobjectequals/AssertObjectEqualsOperationsTestCase.java
...ertobjectequals/AssertObjectEqualsOperationsTestCase.java
+36
-0
src/test/resources/test-mule-config.xml
src/test/resources/test-mule-config.xml
+19
-0
No files found.
README.md
0 → 100644
View file @
4d7b57b0
# AssertObjectEquals Extension
Add description ...
...
...
Add this dependency to your application pom.xml
```
<groupId>de.codecentric.mule.modules</groupId>
<artifactId>assert-object-equals-module</artifactId>
<version>1.0.0-SNAPSHOT</version>
<classifier>mule-plugin</classifier>
```
pom.xml
0 → 100644
View file @
4d7b57b0
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
de.codecentric.mule.modules
</groupId>
<artifactId>
assert-object-equals-module
</artifactId>
<version>
1.0.0-SNAPSHOT
</version>
<packaging>
mule-extension
</packaging>
<name>
AssertObjectEquals Extension
</name>
<parent>
<groupId>
org.mule.extensions
</groupId>
<artifactId>
mule-modules-parent
</artifactId>
<version>
1.1.3
</version>
</parent>
</project>
src/main/java/de/codecentric/mule/modules/assertobjectequals/internal/AssertObjectEqualsConfiguration.java
0 → 100644
View file @
4d7b57b0
package
de.codecentric.mule.modules.assertobjectequals.internal
;
import
org.mule.runtime.extension.api.annotation.Operations
;
import
org.mule.runtime.extension.api.annotation.connectivity.ConnectionProviders
;
import
org.mule.runtime.extension.api.annotation.param.Parameter
;
/**
* This class represents an extension configuration, values set in this class are commonly used across multiple
* operations since they represent something core from the extension.
*/
@Operations
(
AssertObjectEqualsOperations
.
class
)
@ConnectionProviders
(
AssertObjectEqualsConnectionProvider
.
class
)
public
class
AssertObjectEqualsConfiguration
{
@Parameter
private
String
configId
;
public
String
getConfigId
(){
return
configId
;
}
}
src/main/java/de/codecentric/mule/modules/assertobjectequals/internal/AssertObjectEqualsConnection.java
0 → 100644
View file @
4d7b57b0
package
de.codecentric.mule.modules.assertobjectequals.internal
;
/**
* This class represents an extension connection just as example (there is no real connection with anything here c:).
*/
public
final
class
AssertObjectEqualsConnection
{
private
final
String
id
;
public
AssertObjectEqualsConnection
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getId
()
{
return
id
;
}
public
void
invalidate
()
{
// do something to invalidate this connection!
}
}
src/main/java/de/codecentric/mule/modules/assertobjectequals/internal/AssertObjectEqualsConnectionProvider.java
0 → 100644
View file @
4d7b57b0
package
de.codecentric.mule.modules.assertobjectequals.internal
;
import
org.mule.runtime.api.connection.ConnectionException
;
import
org.mule.runtime.extension.api.annotation.param.Parameter
;
import
org.mule.runtime.extension.api.annotation.param.Optional
;
import
org.mule.runtime.api.connection.ConnectionValidationResult
;
import
org.mule.runtime.api.connection.PoolingConnectionProvider
;
import
org.mule.runtime.api.connection.ConnectionProvider
;
import
org.mule.runtime.api.connection.CachedConnectionProvider
;
import
org.mule.runtime.extension.api.annotation.param.display.DisplayName
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* This class (as it's name implies) provides connection instances and the funcionality to disconnect and validate those
* connections.
* <p>
* All connection related parameters (values required in order to create a connection) must be
* declared in the connection providers.
* <p>
* This particular example is a {@link PoolingConnectionProvider} which declares that connections resolved by this provider
* will be pooled and reused. There are other implementations like {@link CachedConnectionProvider} which lazily creates and
* caches connections or simply {@link ConnectionProvider} if you want a new connection each time something requires one.
*/
public
class
AssertObjectEqualsConnectionProvider
implements
PoolingConnectionProvider
<
AssertObjectEqualsConnection
>
{
private
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
AssertObjectEqualsConnectionProvider
.
class
);
/**
* A parameter that is always required to be configured.
*/
@Parameter
private
String
requiredParameter
;
/**
* A parameter that is not required to be configured by the user.
*/
@DisplayName
(
"Friendly Name"
)
@Parameter
@Optional
(
defaultValue
=
"100"
)
private
int
optionalParameter
;
@Override
public
AssertObjectEqualsConnection
connect
()
throws
ConnectionException
{
return
new
AssertObjectEqualsConnection
(
requiredParameter
+
":"
+
optionalParameter
);
}
@Override
public
void
disconnect
(
AssertObjectEqualsConnection
connection
)
{
try
{
connection
.
invalidate
();
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Error while disconnecting ["
+
connection
.
getId
()
+
"]: "
+
e
.
getMessage
(),
e
);
}
}
@Override
public
ConnectionValidationResult
validate
(
AssertObjectEqualsConnection
connection
)
{
return
ConnectionValidationResult
.
success
();
}
}
src/main/java/de/codecentric/mule/modules/assertobjectequals/internal/AssertObjectEqualsExtension.java
0 → 100644
View file @
4d7b57b0
package
de.codecentric.mule.modules.assertobjectequals.internal
;
import
org.mule.runtime.extension.api.annotation.Extension
;
import
org.mule.runtime.extension.api.annotation.Configurations
;
import
org.mule.runtime.extension.api.annotation.dsl.xml.Xml
;
/**
* This is the main class of an extension, is the entry point from which configurations, connection providers, operations
* and sources are going to be declared.
*/
@Xml
(
prefix
=
"assertobjectequals"
)
@Extension
(
name
=
"AssertObjectEquals"
)
@Configurations
(
AssertObjectEqualsConfiguration
.
class
)
public
class
AssertObjectEqualsExtension
{
}
src/main/java/de/codecentric/mule/modules/assertobjectequals/internal/AssertObjectEqualsOperations.java
0 → 100644
View file @
4d7b57b0
package
de.codecentric.mule.modules.assertobjectequals.internal
;
import
static
org
.
mule
.
runtime
.
extension
.
api
.
annotation
.
param
.
MediaType
.
ANY
;
import
org.mule.runtime.extension.api.annotation.param.MediaType
;
import
org.mule.runtime.extension.api.annotation.param.Config
;
import
org.mule.runtime.extension.api.annotation.param.Connection
;
/**
* This class is a container for operations, every public method in this class will be taken as an extension operation.
*/
public
class
AssertObjectEqualsOperations
{
/**
* Example of an operation that uses the configuration and a connection instance to perform some action.
*/
@MediaType
(
value
=
ANY
,
strict
=
false
)
public
String
retrieveInfo
(
@Config
AssertObjectEqualsConfiguration
configuration
,
@Connection
AssertObjectEqualsConnection
connection
){
return
"Using Configuration ["
+
configuration
.
getConfigId
()
+
"] with Connection id ["
+
connection
.
getId
()
+
"]"
;
}
/**
* Example of a simple operation that receives a string parameter and returns a new string message that will be set on the payload.
*/
@MediaType
(
value
=
ANY
,
strict
=
false
)
public
String
sayHi
(
String
person
)
{
return
buildHelloMessage
(
person
);
}
/**
* Private Methods are not exposed as operations
*/
private
String
buildHelloMessage
(
String
person
)
{
return
"Hello "
+
person
+
"!!!"
;
}
}
src/test/java/de/codecentric/mule/modules/assertobjectequals/AssertObjectEqualsOperationsTestCase.java
0 → 100644
View file @
4d7b57b0
package
de.codecentric.mule.modules.assertobjectequals
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
core
.
Is
.
is
;
import
org.mule.functional.junit4.MuleArtifactFunctionalTestCase
;
import
org.junit.Test
;
public
class
AssertObjectEqualsOperationsTestCase
extends
MuleArtifactFunctionalTestCase
{
/**
* Specifies the mule config xml with the flows that are going to be executed in the tests, this file lives in the test resources.
*/
@Override
protected
String
getConfigFile
()
{
return
"test-mule-config.xml"
;
}
@Test
public
void
executeSayHiOperation
()
throws
Exception
{
String
payloadValue
=
((
String
)
flowRunner
(
"sayHiFlow"
).
run
()
.
getMessage
()
.
getPayload
()
.
getValue
());
assertThat
(
payloadValue
,
is
(
"Hello Mariano Gonzalez!!!"
));
}
@Test
public
void
executeRetrieveInfoOperation
()
throws
Exception
{
String
payloadValue
=
((
String
)
flowRunner
(
"retrieveInfoFlow"
)
.
run
()
.
getMessage
()
.
getPayload
()
.
getValue
());
assertThat
(
payloadValue
,
is
(
"Using Configuration [configId] with Connection id [aValue:100]"
));
}
}
src/test/resources/test-mule-config.xml
0 → 100644
View file @
4d7b57b0
<mule
xmlns=
"http://www.mulesoft.org/schema/mule/core"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:assertobjectequals=
"http://www.mulesoft.org/schema/mule/assertobjectequals"
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/assertobjectequals http://www.mulesoft.org/schema/mule/assertobjectequals/current/mule-assertobjectequals.xsd"
>
<assertobjectequals:config
name=
"config"
configId=
"configId"
>
<assertobjectequals:connection
requiredParameter=
"aValue"
/>
</assertobjectequals:config>
<flow
name=
"sayHiFlow"
>
<assertobjectequals:say-hi
person=
"Mariano Gonzalez"
/>
</flow>
<flow
name=
"retrieveInfoFlow"
>
<assertobjectequals:retrieve-info
config-ref=
"config"
/>
</flow>
</mule>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment