Skip to content

Commit 8582eca

Browse files
authored
Merge pull request #54 from Sandro642/fix/ApiFactory
Fix/api factory
2 parents a7813b6 + a201d62 commit 8582eca

3 files changed

Lines changed: 36 additions & 6 deletions

File tree

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.3.9-STABLE'
8+
version = '0.3.9.1-STABLE'
99

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

src/main/java/fr/sandro642/github/api/ApiFactory.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public <O> Object getData(O type) {
7676
return null;
7777
}
7878

79-
return rawData.get(type.toString().toLowerCase());
79+
return rawData.get(type.toString());
8080
} catch (Exception e) {
8181
connectLib.Logger().ERROR(connectLib.LangManager().getMessage(CategoriesType.APIFACTORY_CLASS, "getdata.error", Map.of("type", type.toString(), "exception", e.getMessage())));
8282
}
@@ -98,10 +98,11 @@ public <O, K> Object getSpecData(O type, K value) {
9898
return null;
9999
}
100100

101-
Object nested = rawData.get(type.toString().toLowerCase());
101+
Object nested = rawData.get(type.toString());
102102
if (nested instanceof Map) {
103103
Map<?, ?> nestedMap = (Map<?, ?>) nested;
104-
return nestedMap.get(value.toString().toLowerCase());
104+
105+
return nestedMap.get(value.toString());
105106
}
106107
} catch (Exception e) {
107108
connectLib.Logger().ERROR(connectLib.LangManager().getMessage(CategoriesType.APIFACTORY_CLASS, "getspecdata.error", Map.of("type", type.toString(), "value", value.toString(), "exception", e.getMessage())));

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public class MainTest {
2828

2929
public enum TestRoutes implements RouteImport {
3030
HELLO("/hello"),
31-
GREET("greet$name$")
31+
GREET("greet$name$"),
32+
REQUEST_TOKEN("/auth/request/token")
3233
;
3334

3435
final String route;
@@ -47,7 +48,9 @@ public String getRoute() {
4748
* Example of URL branches, you can add multiple branches if you have multiple environments (dev, prod, etc.)
4849
*/
4950
public enum ExampleUrlBranch implements URLProvider {
50-
LOCALHOST("http://localhost:8080")
51+
LOCALHOST("http://localhost:8080"),
52+
POST_PROD("https://post-prod.systemsolutiongroup.xyz/"),
53+
PROD("https://api.safe-project.systemsolutiongroup.xyz/")
5154
;
5255

5356
private final String url;
@@ -64,6 +67,7 @@ public String getURL() {
6467

6568
public enum TestCustomVersion implements VersionProvider {
6669
DEV_BRANCH("dev"),
70+
V1_API("v1/api")
6771
;
6872

6973
private final String version;
@@ -154,4 +158,29 @@ public void testLangType() {
154158
}
155159
}
156160

161+
162+
@Test
163+
public void testSpecData() {
164+
try {
165+
166+
connectLib.Init(ResourceType.MAIN_RESOURCES, LangType.ENGLISH, TestRoutes.class);
167+
168+
CompletableFuture<ApiFactory> apiFactoryCompletableFuture = connectLib.JobGetInfos()
169+
.getRoutes(TestCustomVersion.V1_API, MethodType.GET, TestRoutes.REQUEST_TOKEN)
170+
.urlBranch(ExampleUrlBranch.PROD)
171+
.getResponse();
172+
173+
ApiFactory apiFactory = apiFactoryCompletableFuture.get(5, TimeUnit.SECONDS);
174+
175+
System.out.println("Réponse brute: " + apiFactory.display());
176+
177+
System.out.println("Data: " + apiFactory.getData("data"));
178+
179+
System.out.println(apiFactory.getSpecData("data", "accessToken"));
180+
181+
} catch (Exception e) {
182+
e.printStackTrace();
183+
}
184+
}
185+
157186
}

0 commit comments

Comments
 (0)