Skip to content

Commit 655c487

Browse files
authored
Merge branch 'main' into feature/easy-rts
2 parents 0e749b9 + d6635ca commit 655c487

5 files changed

Lines changed: 49 additions & 25 deletions

File tree

.github/workflows/work-jar.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ on:
33
push:
44
branches:
55
- main
6-
- Feature/AtomicFactory
76
permissions:
87
contents: write
98
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.5-STABLE'
99

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public JobGetInfos urlBranch(URLProvider urlBranch) {
167167
* makes the API call, and returns the response as an ApiFactory object.
168168
* @return ApiFactory containing the response from the API, or null if an error occurs.
169169
*/
170-
public CompletableFuture<ApiFactory> getResponse() {
170+
public CompletableFuture<ApiFactory> execute() {
171171
try {
172172
String route = (String) connectLib.StoreAndRetrieve().store.get("currentRoute");
173173
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: 29 additions & 22 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;
@@ -44,6 +45,19 @@ public String getRoute() {
4445
}
4546
}
4647

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

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

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

@@ -118,10 +132,8 @@ public void testUseFullRoute() {
118132
);
119133

120134
CompletableFuture<ApiFactory> factoryCompletableFuture = connectLib.JobGetInfos()
121-
.getRoutes(null, MethodType.GET, TestRoutes.GREET)
122-
.urlBranch(ExampleUrlBranch.POST_PROD)
123-
.query(query)
124-
.getResponse();
135+
.getRoutes(MethodType.GET, TestRoutes.GREET)
136+
.execute();
125137

126138
ApiFactory response = factoryCompletableFuture.get(5, TimeUnit.SECONDS);
127139

@@ -148,7 +160,7 @@ public void testLangType() {
148160
*/
149161
//.urlBranch(ExampleUrlBranch.LOCALHOST)
150162

151-
.getResponse();
163+
.execute();
152164

153165
ApiFactory response = factoryCompletableFuture.get(5, TimeUnit.SECONDS);
154166

@@ -178,7 +190,7 @@ public void testSpecData() {
178190
CompletableFuture<ApiFactory> apiFactoryCompletableFuture = connectLib.JobGetInfos()
179191
.getRoutes(TestCustomVersion.V1_API, MethodType.GET, TestRoutes.REQUEST_TOKEN)
180192
.urlBranch(ExampleUrlBranch.PROD)
181-
.getResponse();
193+
.execute();
182194

183195
ApiFactory apiFactory = apiFactoryCompletableFuture.get(5, TimeUnit.SECONDS);
184196

@@ -222,23 +234,18 @@ public void pushsession() {
222234
public void startAppServices() {
223235
try {
224236
connectLib.Logger().showLogs();
225-
connectLib.init(ResourceType.TEST_RESOURCES, LangType.ENGLISH, TestRoutes.class)
226-
.webServices(8080, "TestDashboard");
227-
228-
CompletableFuture<ApiFactory> apiFactoryCompletableFuture = connectLib.JobGetInfos()
229-
.getRoutes(null, MethodType.GET, TestRoutes.HELLO)
230-
.getResponse();
237+
connectLib.init(ResourceType.TEST_RESOURCES, LangType.ENGLISH, TestRoutes.class);
238+
//.webServices(8080, "TestDashboard");
231239

232-
apiFactoryCompletableFuture = connectLib.JobGetInfos()
233-
.getRoutes(TestCustomVersion.V1_API ,MethodType.GET, TestRoutes.REQUEST_TOKEN)
234-
.urlBranch(ExampleUrlBranch.PROD)
235-
.getResponse();
236-
237-
ApiFactory apiFactory = apiFactoryCompletableFuture.get(5, TimeUnit.SECONDS);
240+
CompletableFuture<ClassheritFromFactory> apiFactoryCompletableFuture = connectLib.JobGetInfos()
241+
.getRoutes(MethodType.GET, TestRoutes.HELLO)
242+
.urlBranch(ExampleUrlBranch.POST_PROD)
243+
.execute()
244+
.thenApply(ClassheritFromFactory::new);
238245

239-
System.out.println("Response: " + apiFactory.display());
246+
ClassheritFromFactory classheritFromFactory = apiFactoryCompletableFuture.get(5, TimeUnit.SECONDS);
240247

241-
Thread.sleep(20000);
248+
System.out.println("Response: " + classheritFromFactory.getContent());
242249

243250
} catch (Exception e) {
244251
e.printStackTrace();

0 commit comments

Comments
 (0)