forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include test case for quarkusio#31153
Fix the test case for quarkusio#31153
- Loading branch information
Showing
4 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
core/deployment/src/test/java/io/quarkus/deployment/recording/JobDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package io.quarkus.deployment.recording; | ||
|
||
import static java.util.Collections.unmodifiableList; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class JobDetails { | ||
|
||
private final String className; | ||
private final String staticFieldName; | ||
private final String methodName; | ||
private final ArrayList<JobParameter> jobParameters; | ||
private Boolean cacheable; | ||
|
||
private JobDetails() { | ||
this(null, null, null, null); | ||
// used for deserialization | ||
} | ||
|
||
public JobDetails(String className, String staticFieldName, String methodName, List<JobParameter> jobParameters) { | ||
this.className = className; | ||
this.staticFieldName = staticFieldName; | ||
this.methodName = methodName; | ||
this.jobParameters = new ArrayList<>(jobParameters); | ||
this.cacheable = false; | ||
} | ||
|
||
public String getClassName() { | ||
return className; | ||
} | ||
|
||
public String getStaticFieldName() { | ||
return staticFieldName; | ||
} | ||
|
||
public boolean hasStaticFieldName() { | ||
return staticFieldName != null; | ||
} | ||
|
||
public String getMethodName() { | ||
return methodName; | ||
} | ||
|
||
public List<JobParameter> getJobParameters() { | ||
return unmodifiableList(jobParameters); | ||
} | ||
|
||
public Class[] getJobParameterTypes() { | ||
return jobParameters.stream() | ||
.map(JobParameter::getClassName) | ||
.toArray(Class[]::new); | ||
} | ||
|
||
public Object[] getJobParameterValues() { | ||
return jobParameters.stream() | ||
.map(JobParameter::getObject) | ||
.toArray(); | ||
} | ||
|
||
public Boolean getCacheable() { | ||
return cacheable; | ||
} | ||
|
||
public void setCacheable(boolean cacheable) { | ||
this.cacheable = cacheable; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (!(o instanceof JobDetails)) | ||
return false; | ||
JobDetails that = (JobDetails) o; | ||
return Objects.equals(className, that.className) | ||
&& Objects.equals(staticFieldName, that.staticFieldName) | ||
&& Objects.equals(methodName, that.methodName) | ||
&& Objects.equals(jobParameters, that.jobParameters) | ||
&& Objects.equals(cacheable, that.cacheable); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(className, staticFieldName, methodName, jobParameters, cacheable); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
core/deployment/src/test/java/io/quarkus/deployment/recording/JobParameter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package io.quarkus.deployment.recording; | ||
|
||
import java.util.Objects; | ||
|
||
public class JobParameter { | ||
public static final JobParameter JobContext = new JobParameter(JobParameter.class); | ||
|
||
private String className; | ||
private String actualClassName; | ||
private Object object; | ||
|
||
private JobParameter() { | ||
// used for deserialization | ||
} | ||
|
||
private JobParameter(Class<?> clazz) { | ||
this(clazz.getName(), null); | ||
} | ||
|
||
public JobParameter(Class<?> clazz, Object object) { | ||
this(clazz.getName(), object); | ||
} | ||
|
||
public JobParameter(Object object) { | ||
this(object.getClass().getName(), object); | ||
} | ||
|
||
public JobParameter(String className, Object object) { | ||
this(className, isNotNullNorAnEnum(object) ? object.getClass().getName() : className, object); | ||
} | ||
|
||
public JobParameter(String className, String actualClassName, Object object) { | ||
this.className = className; | ||
this.actualClassName = actualClassName; | ||
this.object = object; | ||
} | ||
|
||
/** | ||
* Represents the class name expected by the job method (e.g. an object or an interface) | ||
* | ||
* @return the class name expected by the job method (e.g. an object or an interface) | ||
*/ | ||
public String getClassName() { | ||
return className; | ||
} | ||
|
||
/** | ||
* Represents the actual class name of the job parameter (e.g. an object), this will never be an interface | ||
* | ||
* @return the actual class name of the job parameter (e.g. an object), this will never be an interface | ||
*/ | ||
public String getActualClassName() { | ||
return actualClassName; | ||
} | ||
|
||
/** | ||
* The actual job parameter | ||
* | ||
* @return the actual job parameter | ||
*/ | ||
public Object getObject() { | ||
return object; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (!(o instanceof JobParameter)) | ||
return false; | ||
JobParameter that = (JobParameter) o; | ||
return Objects.equals(className, that.className) | ||
&& Objects.equals(actualClassName, that.actualClassName) | ||
&& Objects.equals(object, that.object); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(className, actualClassName, object); | ||
} | ||
|
||
protected static boolean isNotNullNorAnEnum(Object object) { | ||
return object != null && !(object instanceof Enum); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters