Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/work-jar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
branches:
- main
- Feature/AtomicFactory
- feature/AtomicFactory
permissions:
contents: write
pages: write
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'fr.sandro642.github'
version = '0.4.3.1-STABLE'
version = '0.4.4-DEV_BUILD'

// Générer une classe de version automatiquement
task generateVersionClass {
Expand Down
107 changes: 0 additions & 107 deletions src/main/java/fr/sandro642/github/example/ExampleUsages.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/fr/sandro642/github/jobs/JobGetInfos.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public JobGetInfos urlBranch(URLProvider urlBranch) {
* makes the API call, and returns the response as an ApiFactory object.
* @return ApiFactory containing the response from the API, or null if an error occurs.
*/
public CompletableFuture<ApiFactory> getResponse() {
public CompletableFuture<ApiFactory> execute() {
try {
String route = (String) connectLib.StoreAndRetrieve().store.get("currentRoute");
MethodType method = (MethodType) connectLib.StoreAndRetrieve().store.get("currentMethod");
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/fr/sandro642/github/provider/AtomicFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package fr.sandro642.github.provider;

import fr.sandro642.github.api.ApiFactory;

import java.util.Map;

public abstract class AtomicFactory {

private ApiFactory apiFactory;

protected void getPhysx(ApiFactory apiFactory) {
this.apiFactory = apiFactory;
}

protected Map<?,?> rawPhysx() {
Copy link

Copilot AI Nov 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rawPhysx() method doesn't check if apiFactory is null before calling getRawData(). If this method is called before getPhysx() is invoked, it will throw a NullPointerException. Consider adding a null check or initializing the field appropriately.

Suggested change
protected Map<?,?> rawPhysx() {
protected Map<?,?> rawPhysx() {
if (apiFactory == null) {
throw new IllegalStateException("ApiFactory has not been initialized. Call getPhysx() first.");
}

Copilot uses AI. Check for mistakes.
return apiFactory.getRawData();
}
}
43 changes: 26 additions & 17 deletions src/test/java/fr/sandro642/github/test/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import fr.sandro642.github.enums.LangType;
import fr.sandro642.github.enums.MethodType;
import fr.sandro642.github.enums.ResourceType;
import fr.sandro642.github.provider.AtomicFactory;
import fr.sandro642.github.provider.RouteImport;
import fr.sandro642.github.provider.URLProvider;
import fr.sandro642.github.provider.VersionProvider;
Expand Down Expand Up @@ -43,6 +44,19 @@ public String getRoute() {
}
}

public class ClassheritFromFactory extends AtomicFactory {
Copy link

Copilot AI Nov 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClassheritFromFactory should be made static, since the enclosing instance is not used.

Suggested change
public class ClassheritFromFactory extends AtomicFactory {
public static class ClassheritFromFactory extends AtomicFactory {

Copilot uses AI. Check for mistakes.



public ClassheritFromFactory(ApiFactory apiFactory) {
Comment on lines +47 to +51
Copy link

Copilot AI Nov 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in class name: "Classherit" should be "ClassInherit" or "ClassThatInherits". The current name appears to be missing "In" between "Class" and "herit".

Suggested change
public class ClassheritFromFactory extends AtomicFactory {
public ClassheritFromFactory(ApiFactory apiFactory) {
public class ClassInheritFromFactory extends AtomicFactory {
public ClassInheritFromFactory(ApiFactory apiFactory) {

Copilot uses AI. Check for mistakes.
getPhysx(apiFactory);
}

public Object getContent() {
return rawPhysx().get("content");
}
}

/**
* Example of URL branches, you can add multiple branches if you have multiple environments (dev, prod, etc.)
*/
Expand Down Expand Up @@ -94,7 +108,7 @@ public static void main(String[] args) {

CompletableFuture<ApiFactory> apiFactoryCompletableFuture = connectLib.JobGetInfos()
.getRoutes(MethodType.GET, TestRoutes.HELLO)
.getResponse();
.execute();

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

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

CompletableFuture<ApiFactory> factoryCompletableFuture = connectLib.JobGetInfos()
.getRoutes(MethodType.GET, TestRoutes.GREET, null, null, query)
.getResponse();
.execute();

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

Expand All @@ -145,7 +159,7 @@ public void testLangType() {
*/
//.urlBranch(ExampleUrlBranch.LOCALHOST)

.getResponse();
.execute();

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

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

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

Expand All @@ -186,23 +200,18 @@ public void testSpecData() {
public void startAppServices() {
try {
connectLib.Logger().showLogs();
connectLib.init(ResourceType.TEST_RESOURCES, LangType.ENGLISH, TestRoutes.class)
.webServices(8080, "TestDashboard");
connectLib.init(ResourceType.TEST_RESOURCES, LangType.ENGLISH, TestRoutes.class);
//.webServices(8080, "TestDashboard");

CompletableFuture<ApiFactory> apiFactoryCompletableFuture = connectLib.JobGetInfos()
CompletableFuture<ClassheritFromFactory> apiFactoryCompletableFuture = connectLib.JobGetInfos()
Copy link

Copilot AI Nov 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in type reference: "ClassheritFromFactory" should be "ClassInheritFromFactory" to match proper spelling.

Copilot uses AI. Check for mistakes.
.getRoutes(MethodType.GET, TestRoutes.HELLO)
.getResponse();

apiFactoryCompletableFuture = connectLib.JobGetInfos()
.getRoutes(TestCustomVersion.V1_API ,MethodType.GET, TestRoutes.REQUEST_TOKEN)
.urlBranch(ExampleUrlBranch.PROD)
.getResponse();

ApiFactory apiFactory = apiFactoryCompletableFuture.get(5, TimeUnit.SECONDS);
.urlBranch(ExampleUrlBranch.POST_PROD)
.execute()
.thenApply(ClassheritFromFactory::new);
Copy link

Copilot AI Nov 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in type reference: "ClassheritFromFactory" should be "ClassInheritFromFactory" to match proper spelling.

Copilot uses AI. Check for mistakes.

System.out.println("Response: " + apiFactory.display());
ClassheritFromFactory classheritFromFactory = apiFactoryCompletableFuture.get(5, TimeUnit.SECONDS);
Copy link

Copilot AI Nov 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in variable name: "classherit" should be "classInherit" to match proper spelling and be consistent with the class name correction.

Copilot uses AI. Check for mistakes.

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

} catch (Exception e) {
e.printStackTrace();
Expand Down
Loading