Skip to content

Commit 3a08287

Browse files
committed
Fix #368 - Introduce Standard Fluent DSL
Signed-off-by: Ricardo Zanini <[email protected]>
1 parent 14d25e9 commit 3a08287

29 files changed

+2498
-0
lines changed

fluent/pom.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>io.serverlessworkflow</groupId>
8+
<artifactId>serverlessworkflow-parent</artifactId>
9+
<version>8.0.0-SNAPSHOT</version>
10+
</parent>
11+
<name>Serverless Workflow :: Fluent</name>
12+
<artifactId>serverlessworkflow-fluent</artifactId>
13+
<packaging>pom</packaging>
14+
15+
<properties>
16+
<maven.compiler.source>17</maven.compiler.source>
17+
<maven.compiler.target>17</maven.compiler.target>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
</properties>
20+
21+
<dependencyManagement>
22+
<dependencies>
23+
<dependency>
24+
<groupId>io.serverlessworkflow</groupId>
25+
<artifactId>serverlessworkflow-types</artifactId>
26+
<version>${project.version}</version>
27+
</dependency>
28+
</dependencies>
29+
</dependencyManagement>
30+
31+
<modules>
32+
<module>standard</module>
33+
</modules>
34+
35+
</project>

fluent/standard/pom.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>io.serverlessworkflow</groupId>
8+
<artifactId>serverlessworkflow-fluent</artifactId>
9+
<version>8.0.0-SNAPSHOT</version>
10+
</parent>
11+
<name>Serverless Workflow :: Fluent :: Standard</name>
12+
<artifactId>serverlessworkflow-fluent-standard</artifactId>
13+
14+
<properties>
15+
<maven.compiler.source>17</maven.compiler.source>
16+
<maven.compiler.target>17</maven.compiler.target>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
19+
20+
<dependencies>
21+
<dependency>
22+
<groupId>io.serverlessworkflow</groupId>
23+
<artifactId>serverlessworkflow-types</artifactId>
24+
</dependency>
25+
<dependency>
26+
<groupId>org.junit.jupiter</groupId>
27+
<artifactId>junit-jupiter-api</artifactId>
28+
<scope>test</scope>
29+
</dependency>
30+
</dependencies>
31+
32+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.fluent.standard;
17+
18+
import io.serverlessworkflow.api.types.AuthenticationPolicyUnion;
19+
import java.util.function.Consumer;
20+
21+
public class AuthenticationPolicyUnionBuilder {
22+
final AuthenticationPolicyUnion authenticationPolicy;
23+
24+
AuthenticationPolicyUnionBuilder() {
25+
this.authenticationPolicy = new AuthenticationPolicyUnion();
26+
}
27+
28+
public AuthenticationPolicyUnionBuilder basic(
29+
Consumer<BasicAuthenticationPolicyBuilder> basicConsumer) {
30+
final BasicAuthenticationPolicyBuilder basicAuthenticationPolicyBuilder =
31+
new BasicAuthenticationPolicyBuilder();
32+
basicConsumer.accept(basicAuthenticationPolicyBuilder);
33+
this.authenticationPolicy.setBasicAuthenticationPolicy(
34+
basicAuthenticationPolicyBuilder.build());
35+
return this;
36+
}
37+
38+
public AuthenticationPolicyUnionBuilder bearer(
39+
Consumer<BearerAuthenticationPolicyBuilder> bearerConsumer) {
40+
final BearerAuthenticationPolicyBuilder bearerAuthenticationPolicyBuilder =
41+
new BearerAuthenticationPolicyBuilder();
42+
bearerConsumer.accept(bearerAuthenticationPolicyBuilder);
43+
this.authenticationPolicy.setBearerAuthenticationPolicy(
44+
bearerAuthenticationPolicyBuilder.build());
45+
return this;
46+
}
47+
48+
public AuthenticationPolicyUnionBuilder digest(
49+
Consumer<DigestAuthenticationPolicyBuilder> digestConsumer) {
50+
final DigestAuthenticationPolicyBuilder digestAuthenticationPolicyBuilder =
51+
new DigestAuthenticationPolicyBuilder();
52+
digestConsumer.accept(digestAuthenticationPolicyBuilder);
53+
this.authenticationPolicy.setDigestAuthenticationPolicy(
54+
digestAuthenticationPolicyBuilder.build());
55+
return this;
56+
}
57+
58+
public AuthenticationPolicyUnionBuilder oauth2(
59+
Consumer<OAuth2AuthenticationPolicyBuilder> oauth2Consumer) {
60+
final OAuth2AuthenticationPolicyBuilder oauth2AuthenticationPolicyBuilder =
61+
new OAuth2AuthenticationPolicyBuilder();
62+
oauth2Consumer.accept(oauth2AuthenticationPolicyBuilder);
63+
this.authenticationPolicy.setOAuth2AuthenticationPolicy(
64+
oauth2AuthenticationPolicyBuilder.build());
65+
return this;
66+
}
67+
68+
public AuthenticationPolicyUnionBuilder openIDConnect(
69+
Consumer<OpenIdConnectAuthenticationPolicyBuilder> openIdConnectConsumer) {
70+
final OpenIdConnectAuthenticationPolicyBuilder builder =
71+
new OpenIdConnectAuthenticationPolicyBuilder();
72+
openIdConnectConsumer.accept(builder);
73+
this.authenticationPolicy.setOpenIdConnectAuthenticationPolicy(builder.build());
74+
return this;
75+
}
76+
77+
public AuthenticationPolicyUnion build() {
78+
return authenticationPolicy;
79+
}
80+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.fluent.standard;
17+
18+
import io.serverlessworkflow.api.types.BasicAuthenticationPolicy;
19+
import io.serverlessworkflow.api.types.BasicAuthenticationPolicyConfiguration;
20+
import io.serverlessworkflow.api.types.BasicAuthenticationProperties;
21+
22+
public final class BasicAuthenticationPolicyBuilder {
23+
24+
private final BasicAuthenticationProperties basicAuthenticationProperties;
25+
26+
BasicAuthenticationPolicyBuilder() {
27+
this.basicAuthenticationProperties = new BasicAuthenticationProperties();
28+
}
29+
30+
public BasicAuthenticationPolicyBuilder username(String username) {
31+
this.basicAuthenticationProperties.setUsername(username);
32+
return this;
33+
}
34+
35+
public BasicAuthenticationPolicyBuilder password(String password) {
36+
this.basicAuthenticationProperties.setPassword(password);
37+
return this;
38+
}
39+
40+
public BasicAuthenticationPolicy build() {
41+
final BasicAuthenticationPolicyConfiguration configuration =
42+
new BasicAuthenticationPolicyConfiguration();
43+
configuration.setBasicAuthenticationProperties(basicAuthenticationProperties);
44+
return new BasicAuthenticationPolicy(configuration);
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.fluent.standard;
17+
18+
import io.serverlessworkflow.api.types.BearerAuthenticationPolicy;
19+
import io.serverlessworkflow.api.types.BearerAuthenticationPolicyConfiguration;
20+
import io.serverlessworkflow.api.types.BearerAuthenticationProperties;
21+
22+
public final class BearerAuthenticationPolicyBuilder {
23+
private final BearerAuthenticationProperties bearerAuthenticationProperties;
24+
25+
BearerAuthenticationPolicyBuilder() {
26+
this.bearerAuthenticationProperties = new BearerAuthenticationProperties();
27+
}
28+
29+
public BearerAuthenticationPolicyBuilder token(final String token) {
30+
this.bearerAuthenticationProperties.setToken(token);
31+
return this;
32+
}
33+
34+
public BearerAuthenticationPolicy build() {
35+
final BearerAuthenticationPolicyConfiguration configuration =
36+
new BearerAuthenticationPolicyConfiguration();
37+
configuration.setBearerAuthenticationProperties(bearerAuthenticationProperties);
38+
return new BearerAuthenticationPolicy(configuration);
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.serverlessworkflow.fluent.standard;
17+
18+
import io.serverlessworkflow.api.types.DigestAuthenticationPolicy;
19+
import io.serverlessworkflow.api.types.DigestAuthenticationPolicyConfiguration;
20+
import io.serverlessworkflow.api.types.DigestAuthenticationProperties;
21+
22+
public final class DigestAuthenticationPolicyBuilder {
23+
private final DigestAuthenticationProperties digestAuthenticationProperties;
24+
25+
DigestAuthenticationPolicyBuilder() {
26+
this.digestAuthenticationProperties = new DigestAuthenticationProperties();
27+
}
28+
29+
public DigestAuthenticationPolicyBuilder username(String username) {
30+
this.digestAuthenticationProperties.setUsername(username);
31+
return this;
32+
}
33+
34+
public DigestAuthenticationPolicyBuilder password(String password) {
35+
this.digestAuthenticationProperties.setPassword(password);
36+
return this;
37+
}
38+
39+
public DigestAuthenticationPolicy build() {
40+
final DigestAuthenticationPolicyConfiguration configuration =
41+
new DigestAuthenticationPolicyConfiguration();
42+
configuration.setDigestAuthenticationProperties(digestAuthenticationProperties);
43+
return new DigestAuthenticationPolicy(configuration);
44+
}
45+
}

0 commit comments

Comments
 (0)