Skip to content

Commit

Permalink
Fixed JobEngine tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Dec 12, 2022
1 parent 608ce24 commit 96fb22d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class GwtJobStepDefinitionServiceImpl extends KapuaRemoteServiceServlet i
public ListLoadResult<GwtJobStepDefinition> findAll() throws GwtKapuaException {
List<GwtJobStepDefinition> gwtJobStepDefinitionList = new ArrayList<GwtJobStepDefinition>();
try {
JobStepDefinitionListResult result = JOB_STEP_DEFINITION_SERVICE.query(JOB_STEP_DEFINITION_FACTORY.newQuery(null));
JobStepDefinitionListResult result = JOB_STEP_DEFINITION_SERVICE.query(JOB_STEP_DEFINITION_FACTORY.newQuery(KapuaId.ANY));
for (JobStepDefinition jsd : result.getItems()) {

if (!Strings.isNullOrEmpty(JOB_STEP_DEFINITION_EXCLUDE_REGEX) && jsd.getName().matches(JOB_STEP_DEFINITION_EXCLUDE_REGEX)) {
Expand All @@ -76,7 +76,7 @@ public GwtJobStepDefinition find(String gwtJobStepDefinitionId) throws GwtKapuaE

GwtJobStepDefinition gwtJobStepDefinition = null;
try {
JobStepDefinition jobStepDefinition = JOB_STEP_DEFINITION_SERVICE.find(null, jobStepDefinitionId);
JobStepDefinition jobStepDefinition = JOB_STEP_DEFINITION_SERVICE.find(KapuaId.ANY, jobStepDefinitionId);
if (jobStepDefinition != null) {
gwtJobStepDefinition = KapuaGwtJobModelConverter.convertJobStepDefinition(jobStepDefinition);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public PagingLoadResult<GwtJobStep> query(PagingLoadConfig loadConfig, GwtJobSte
for (JobStep js : jobStepList.getItems()) {
GwtJobStep gwtJobStep = KapuaGwtJobModelConverter.convertJobStep(js);

JobStepDefinition jobStepDefinition = JOB_STEP_DEFINITION_SERVICE
.find(GwtKapuaCommonsModelConverter.convertKapuaId(gwtJobStep.getScopeId()), GwtKapuaCommonsModelConverter.convertKapuaId(gwtJobStep.getJobStepDefinitionId()));
JobStepDefinition jobStepDefinition = JOB_STEP_DEFINITION_SERVICE.find(KapuaId.ANY, GwtKapuaCommonsModelConverter.convertKapuaId(gwtJobStep.getJobStepDefinitionId()));
gwtJobStep.setJobStepDefinitionName(jobStepDefinition.getName());

setEnumOnJobStepProperty(gwtJobStep.getStepProperties());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static void startJob(@NotNull KapuaId scopeId, @NotNull KapuaId jobId, @N
JobStep jobStep = jobStepIterator.next();

Step jslStep = new Step();
JobStepDefinition jobStepDefinition = STEP_DEFINITION_SERVICE.find(jobStep.getScopeId(), jobStep.getJobStepDefinitionId());
JobStepDefinition jobStepDefinition = STEP_DEFINITION_SERVICE.find(KapuaId.ANY, jobStep.getJobStepDefinitionId());
switch (jobStepDefinition.getStepType()) {
case GENERIC:
jslStep.setBatchlet(JobDefinitionBuildUtils.buildGenericStep(jobStepDefinition));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,14 @@
*******************************************************************************/
package org.eclipse.kapua.app.api.resources.v1.resources;

import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.google.common.base.Strings;
import org.eclipse.kapua.KapuaException;
import org.eclipse.kapua.app.api.core.model.CountResult;
import org.eclipse.kapua.app.api.core.model.EntityId;
import org.eclipse.kapua.app.api.core.model.ScopeId;
import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.model.id.KapuaId;
import org.eclipse.kapua.model.query.SortOrder;
import org.eclipse.kapua.service.KapuaService;
import org.eclipse.kapua.service.job.Job;
Expand All @@ -40,7 +32,15 @@
import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionQuery;
import org.eclipse.kapua.service.job.step.definition.JobStepDefinitionService;

import com.google.common.base.Strings;
import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

@Path("{scopeId}/jobStepDefinitions")
public class JobStepDefinitions extends AbstractKapuaResource {
Expand All @@ -52,11 +52,11 @@ public class JobStepDefinitions extends AbstractKapuaResource {
/**
* Gets the {@link JobStep} list for a given {@link Job}.
*
* @param scopeId The {@link ScopeId} in which to search results.
* @param sortParam The name of the parameter that will be used as a sorting key
* @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive.
* @param offset The result set offset.
* @param limit The result set limit.
* @param scopeId The {@link ScopeId} in which to search results.
* @param sortParam The name of the parameter that will be used as a sorting key
* @param sortDir The sort direction. Can be ASCENDING (default), DESCENDING. Case-insensitive.
* @param offset The result set offset.
* @param limit The result set limit.
* @return The {@link JobStepListResult} of all the jobs jobSteps associated to the current selected job.
* @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions.
* @since 1.5.0
Expand All @@ -70,7 +70,7 @@ public JobStepDefinitionListResult simpleQuery(
@QueryParam("offset") @DefaultValue("0") int offset,
@QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException {

JobStepDefinitionQuery query = jobStepDefinitionFactory.newQuery(null);
JobStepDefinitionQuery query = jobStepDefinitionFactory.newQuery(KapuaId.ANY);

if (!Strings.isNullOrEmpty(sortParam)) {
query.setSortCriteria(query.fieldSortCriteria(sortParam, sortDir));
Expand Down Expand Up @@ -98,7 +98,8 @@ public JobStepDefinitionListResult simpleQuery(
public JobStepDefinitionListResult query(
@PathParam("scopeId") ScopeId scopeId,
JobStepDefinitionQuery query) throws KapuaException {
query.setScopeId(null);
query.setScopeId(KapuaId.ANY);

return jobStepDefinitionService.query(query);
}

Expand All @@ -118,15 +119,15 @@ public JobStepDefinitionListResult query(
public CountResult count(
@PathParam("scopeId") ScopeId scopeId,
JobStepQuery query) throws KapuaException {
query.setScopeId(null);
query.setScopeId(KapuaId.ANY);

return new CountResult(jobStepDefinitionService.count(query));
}

/**
* Returns the Job specified by the "jobId" path parameter.
*
* @param scopeId The {@link ScopeId} of the requested {@link Job}.
* @param scopeId The {@link ScopeId} of the requested {@link Job}.
* @param stepDefinitionId The id of the requested JobStep.
* @return The requested Job object.
* @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions.
Expand All @@ -138,7 +139,7 @@ public CountResult count(
public JobStepDefinition find(
@PathParam("scopeId") ScopeId scopeId,
@PathParam("stepDefinitionId") EntityId stepDefinitionId) throws KapuaException {
return jobStepDefinitionService.find(null, stepDefinitionId);
return jobStepDefinitionService.find(KapuaId.ANY, stepDefinitionId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public void delete(KapuaId scopeId, KapuaId jobStepId) throws KapuaException {
//
// Private methods
private void validateJobStepProperties(JobStepCreator jobStepCreator) throws KapuaException {
JobStepDefinition jobStepDefinition = JOB_STEP_DEFINITION_SERVICE.find(jobStepCreator.getScopeId(), jobStepCreator.getJobStepDefinitionId());
JobStepDefinition jobStepDefinition = JOB_STEP_DEFINITION_SERVICE.find(KapuaId.ANY, jobStepCreator.getJobStepDefinitionId());
ArgumentValidator.notNull(jobStepDefinition, "jobStepCreator.jobStepDefinitionId");

try {
Expand All @@ -334,7 +334,7 @@ private void validateJobStepProperties(JobStepCreator jobStepCreator) throws Kap
}

private void validateJobStepProperties(JobStep jobStep) throws KapuaException {
JobStepDefinition jobStepDefinition = JOB_STEP_DEFINITION_SERVICE.find(jobStep.getScopeId(), jobStep.getJobStepDefinitionId());
JobStepDefinition jobStepDefinition = JOB_STEP_DEFINITION_SERVICE.find(KapuaId.ANY, jobStep.getJobStepDefinitionId());
ArgumentValidator.notNull(jobStepDefinition, "jobStep.jobStepDefinitionId");

try {
Expand Down

0 comments on commit 96fb22d

Please sign in to comment.