Skip to content

Commit c4bdc02

Browse files
authored
Merge pull request #59 from Sandro642/feature/AtomicFactory
Feature/atomic factory
2 parents bf2b6e2 + 867b793 commit c4bdc02

6 files changed

Lines changed: 47 additions & 127 deletions

File tree

.github/workflows/work-jar.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
push:
44
branches:
55
- main
6-
- Feature/AtomicFactory
6+
- feature/AtomicFactory
77
permissions:
88
contents: write
99
pages: write

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = 'fr.sandro642.github'
8-
version = '0.4.3.1-STABLE'
8+
version = '0.4.4-DEV_BUILD'
99

1010
// Générer une classe de version automatiquement
1111
task generateVersionClass {

src/main/java/fr/sandro642/github/example/ExampleUsages.java

Lines changed: 0 additions & 107 deletions
This file was deleted.

src/main/java/fr/sandro642/github/jobs/JobGetInfos.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public JobGetInfos urlBranch(URLProvider urlBranch) {
270270
* makes the API call, and returns the response as an ApiFactory object.
271271
* @return ApiFactory containing the response from the API, or null if an error occurs.
272272
*/
273-
public CompletableFuture<ApiFactory> getResponse() {
273+
public CompletableFuture<ApiFactory> execute() {
274274
try {
275275
String route = (String) connectLib.StoreAndRetrieve().store.get("currentRoute");
276276
MethodType method = (MethodType) connectLib.StoreAndRetrieve().store.get("currentMethod");
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package fr.sandro642.github.provider;
2+
3+
import fr.sandro642.github.api.ApiFactory;
4+
5+
import java.util.Map;
6+
7+
public abstract class AtomicFactory {
8+
9+
private ApiFactory apiFactory;
10+
11+
protected void getPhysx(ApiFactory apiFactory) {
12+
this.apiFactory = apiFactory;
13+
}
14+
15+
protected Map<?,?> rawPhysx() {
16+
return apiFactory.getRawData();
17+
}
18+
}

src/test/java/fr/sandro642/github/test/MainTest.java

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import fr.sandro642.github.enums.LangType;
77
import fr.sandro642.github.enums.MethodType;
88
import fr.sandro642.github.enums.ResourceType;
9+
import fr.sandro642.github.provider.AtomicFactory;
910
import fr.sandro642.github.provider.RouteImport;
1011
import fr.sandro642.github.provider.URLProvider;
1112
import fr.sandro642.github.provider.VersionProvider;
@@ -43,6 +44,19 @@ public String getRoute() {
4344
}
4445
}
4546

47+
public class ClassheritFromFactory extends AtomicFactory {
48+
49+
50+
51+
public ClassheritFromFactory(ApiFactory apiFactory) {
52+
getPhysx(apiFactory);
53+
}
54+
55+
public Object getContent() {
56+
return rawPhysx().get("content");
57+
}
58+
}
59+
4660
/**
4761
* Example of URL branches, you can add multiple branches if you have multiple environments (dev, prod, etc.)
4862
*/
@@ -94,7 +108,7 @@ public static void main(String[] args) {
94108

95109
CompletableFuture<ApiFactory> apiFactoryCompletableFuture = connectLib.JobGetInfos()
96110
.getRoutes(MethodType.GET, TestRoutes.HELLO)
97-
.getResponse();
111+
.execute();
98112

99113
ApiFactory response = apiFactoryCompletableFuture.get(5, TimeUnit.SECONDS);
100114

@@ -118,7 +132,7 @@ public void testUseFullRoute() {
118132

119133
CompletableFuture<ApiFactory> factoryCompletableFuture = connectLib.JobGetInfos()
120134
.getRoutes(MethodType.GET, TestRoutes.GREET, null, null, query)
121-
.getResponse();
135+
.execute();
122136

123137
ApiFactory response = factoryCompletableFuture.get(5, TimeUnit.SECONDS);
124138

@@ -145,7 +159,7 @@ public void testLangType() {
145159
*/
146160
//.urlBranch(ExampleUrlBranch.LOCALHOST)
147161

148-
.getResponse();
162+
.execute();
149163

150164
ApiFactory response = factoryCompletableFuture.get(5, TimeUnit.SECONDS);
151165

@@ -167,7 +181,7 @@ public void testSpecData() {
167181
CompletableFuture<ApiFactory> apiFactoryCompletableFuture = connectLib.JobGetInfos()
168182
.getRoutes(TestCustomVersion.V1_API, MethodType.GET, TestRoutes.REQUEST_TOKEN)
169183
.urlBranch(ExampleUrlBranch.PROD)
170-
.getResponse();
184+
.execute();
171185

172186
ApiFactory apiFactory = apiFactoryCompletableFuture.get(5, TimeUnit.SECONDS);
173187

@@ -186,23 +200,18 @@ public void testSpecData() {
186200
public void startAppServices() {
187201
try {
188202
connectLib.Logger().showLogs();
189-
connectLib.init(ResourceType.TEST_RESOURCES, LangType.ENGLISH, TestRoutes.class)
190-
.webServices(8080, "TestDashboard");
203+
connectLib.init(ResourceType.TEST_RESOURCES, LangType.ENGLISH, TestRoutes.class);
204+
//.webServices(8080, "TestDashboard");
191205

192-
CompletableFuture<ApiFactory> apiFactoryCompletableFuture = connectLib.JobGetInfos()
206+
CompletableFuture<ClassheritFromFactory> apiFactoryCompletableFuture = connectLib.JobGetInfos()
193207
.getRoutes(MethodType.GET, TestRoutes.HELLO)
194-
.getResponse();
195-
196-
apiFactoryCompletableFuture = connectLib.JobGetInfos()
197-
.getRoutes(TestCustomVersion.V1_API ,MethodType.GET, TestRoutes.REQUEST_TOKEN)
198-
.urlBranch(ExampleUrlBranch.PROD)
199-
.getResponse();
200-
201-
ApiFactory apiFactory = apiFactoryCompletableFuture.get(5, TimeUnit.SECONDS);
208+
.urlBranch(ExampleUrlBranch.POST_PROD)
209+
.execute()
210+
.thenApply(ClassheritFromFactory::new);
202211

203-
System.out.println("Response: " + apiFactory.display());
212+
ClassheritFromFactory classheritFromFactory = apiFactoryCompletableFuture.get(5, TimeUnit.SECONDS);
204213

205-
Thread.sleep(20000);
214+
System.out.println("Response: " + classheritFromFactory.getContent());
206215

207216
} catch (Exception e) {
208217
e.printStackTrace();

0 commit comments

Comments
 (0)