Refactor REST Constants (#2881)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2026-01-22 17:06:44 +02:00
committed by GitHub
parent 5d562abd3c
commit 97762360c3
53 changed files with 1201 additions and 1536 deletions

View File

@@ -109,7 +109,7 @@ public class MgmtDistributionSetMapper {
response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getAssignedSoftwareModules(response.getId(),
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE,
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null))
.withRel(MgmtRestConstants.DISTRIBUTIONSET_V1_MODULE).expand());
.withRel("modules").expand());
response.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class)
.getDistributionSetType(distributionSet.getType().getId())).withRel("type").expand());

View File

@@ -24,7 +24,6 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionS
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssignment;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
@@ -76,10 +75,10 @@ public final class MgmtDistributionSetTypeMapper {
public static void addLinks(final MgmtDistributionSetType result) {
result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getMandatoryModules(result.getId()))
.withRel(MgmtRestConstants.MANDATORYMODULES).expand());
.withRel("mandatorymodules").expand());
result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getOptionalModules(result.getId()))
.withRel(MgmtRestConstants.OPTIONALMODULES).expand());
.withRel("optionalmodules").expand());
}
private DistributionSetTypeManagement.Create fromRequest(final MgmtDistributionSetTypeRequestBodyPost smsRest) {

View File

@@ -28,7 +28,6 @@ import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifactHash;
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleMetadata;
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi;
import org.eclipse.hawkbit.mgmt.rest.resource.MgmtDownloadArtifactResource;
@@ -118,9 +117,9 @@ public final class MgmtSoftwareModuleMapper {
public static void addLinks(final SoftwareModule softwareModule, final MgmtSoftwareModule response) {
response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getArtifacts(response.getId(), null, null))
.withRel(MgmtRestConstants.SOFTWAREMODULE_V1_ARTIFACT).expand());
.withRel("artifacts").expand());
response.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(softwareModule.getType().getId()))
.withRel(MgmtRestConstants.SOFTWAREMODULE_V1_TYPE).expand());
.withRel("type").expand());
response.add(WebMvcLinkBuilder.linkTo(methodOn(MgmtSoftwareModuleResource.class).getMetadata(response.getId()))
.withRel("metadata").expand());
}

View File

@@ -81,24 +81,24 @@ public final class MgmtTargetMapper {
*/
public static void addTargetLinks(final MgmtTarget response) {
response.add(linkTo(methodOn(MgmtTargetRestApi.class).getAssignedDistributionSet(response.getControllerId()))
.withRel(MgmtRestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET).expand());
.withRel("assignedDS").expand());
response.add(linkTo(methodOn(MgmtTargetRestApi.class).getInstalledDistributionSet(response.getControllerId()))
.withRel(MgmtRestConstants.TARGET_V1_INSTALLED_DISTRIBUTION_SET).expand());
.withRel("installedDS").expand());
response.add(linkTo(methodOn(MgmtTargetRestApi.class).getAttributes(response.getControllerId()))
.withRel(MgmtRestConstants.TARGET_V1_ATTRIBUTES).expand());
.withRel("attributes").expand());
response.add(linkTo(methodOn(MgmtTargetRestApi.class).getActionHistory(response.getControllerId(), null, 0,
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE,
ActionFields.ID.getName() + ":" + SortDirection.DESC))
.withRel(MgmtRestConstants.TARGET_V1_ACTIONS).expand());
.withRel(MgmtTarget.TARGET_V1_ACTIONS).expand());
response.add(linkTo(methodOn(MgmtTargetRestApi.class).getMetadata(response.getControllerId()))
.withRel("metadata").expand());
if (response.getTargetType() != null) {
response.add(linkTo(methodOn(MgmtTargetTypeRestApi.class).getTargetType(response.getTargetType()))
.withRel(MgmtRestConstants.TARGET_V1_ASSIGNED_TARGET_TYPE).expand());
.withRel(MgmtTarget.TARGET_TYPE).expand());
}
if (response.getAutoConfirmActive() != null) {
response.add(linkTo(methodOn(MgmtTargetRestApi.class).getAutoConfirmStatus(response.getControllerId()))
.withRel(MgmtRestConstants.TARGET_V1_AUTO_CONFIRM).expand());
.withRel(MgmtTarget.AUTO_CONFIRM).expand());
}
}
@@ -110,11 +110,11 @@ public final class MgmtTargetMapper {
response.setInitiator(status.getInitiator());
response.setRemark(status.getRemark());
response.add(linkTo(methodOn(MgmtTargetRestApi.class).deactivateAutoConfirm(target.getControllerId()))
.withRel(MgmtRestConstants.TARGET_V1_DEACTIVATE_AUTO_CONFIRM).expand());
.withRel(MgmtTargetAutoConfirm.DEACTIVATE).expand());
} else {
response = MgmtTargetAutoConfirm.disabled();
response.add(linkTo(methodOn(MgmtTargetRestApi.class).activateAutoConfirm(target.getControllerId(), null))
.withRel(MgmtRestConstants.TARGET_V1_ACTIVATE_AUTO_CONFIRM).expand());
.withRel(MgmtTargetAutoConfirm.ACTIVATE).expand());
}
return response;
}
@@ -263,7 +263,7 @@ public final class MgmtTargetMapper {
if (action.isCancelingOrCanceled()) {
result.add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(controllerId, action.getId()))
.withRel(MgmtRestConstants.TARGET_V1_CANCELED_ACTION).expand());
.withRel("canceledaction").expand());
}
result.add(linkTo(methodOn(MgmtTargetRestApi.class).getTarget(controllerId)).withRel("target")
@@ -277,12 +277,12 @@ public final class MgmtTargetMapper {
result.add(linkTo(methodOn(MgmtTargetRestApi.class).getActionStatusList(controllerId, action.getId(), 0,
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE,
ActionStatusFields.ID.getName() + ":" + SortDirection.DESC))
.withRel(MgmtRestConstants.TARGET_V1_ACTION_STATUS).expand());
.withRel(MgmtTarget.TARGET_V1_ACTION_STATUS).expand());
final Rollout rollout = action.getRollout();
if (rollout != null) {
result.add(linkTo(methodOn(MgmtRolloutRestApi.class).getRollout(rollout.getId()))
.withRel(MgmtRestConstants.TARGET_V1_ROLLOUT).withName(rollout.getName()).expand());
.withRel("rollout").withName(rollout.getName()).expand());
}
return result;

View File

@@ -22,7 +22,6 @@ import java.util.stream.Collectors;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeAssignment;
import org.eclipse.hawkbit.mgmt.json.model.targettype.MgmtTargetType;
import org.eclipse.hawkbit.mgmt.json.model.targettype.MgmtTargetTypeRequestBodyPost;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTypeRestApi;
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
import org.eclipse.hawkbit.repository.TargetTypeManagement;
@@ -74,7 +73,7 @@ public final class MgmtTargetTypeMapper {
public static void addLinks(final MgmtTargetType result) {
result.add(linkTo(methodOn(MgmtTargetTypeRestApi.class).getCompatibleDistributionSets(result.getId()))
.withRel(MgmtRestConstants.COMPATIBLEDISTRIBUTIONSETTYPES).expand());
.withRel(MgmtTargetTypeRestApi.COMPATIBLEDISTRIBUTIONSETTYPES).expand());
}
private TargetTypeManagement.Create fromRequest(final MgmtTargetTypeRequestBodyPost targetTypesRest) {

View File

@@ -10,7 +10,7 @@
package org.eclipse.hawkbit.mgmt.rest.resource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.ACTION_V1_REQUEST_MAPPING;
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtActionRestApi.ACTIONS_V1;
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_SEARCH;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
@@ -27,9 +27,12 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtActionRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -91,7 +94,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final String rsqlPendingOrFinishedStatus = rsqlFinishedStatus + "," + rsqlPendingStatus;
// pending status one result
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingStatus))
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlPendingStatus))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
@@ -99,14 +102,14 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("content[0].active", equalTo(true)));
// finished status none result
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlFinishedStatus))
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlFinishedStatus))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(0)))
.andExpect(jsonPath("size", equalTo(0)));
// pending or finished status one result
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingOrFinishedStatus))
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlPendingOrFinishedStatus))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
@@ -129,7 +132,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final String rsqlPendingOrFinishedStatus = rsqlFinishedStatus + "," + rsqlPendingStatus;
// running status one result
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingStatus))
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlPendingStatus))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
@@ -138,14 +141,14 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("content[0].status", equalTo("running")));
// finished status none result
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlFinishedStatus))
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlFinishedStatus))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(0)))
.andExpect(jsonPath("size", equalTo(0)));
// running or finished status one result
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingOrFinishedStatus))
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlPendingOrFinishedStatus))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
@@ -177,7 +180,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final String rsqlExtRefNoMatch = "externalref==234extRef";
// pending status one result
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRef))
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlExtRef))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
@@ -185,14 +188,14 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("content[0].externalRef", equalTo(externalRefs.get(0))));
// finished status none result
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRefWildcard))
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlExtRefWildcard))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(2)))
.andExpect(jsonPath("size", equalTo(2)));
// pending or finished status one result
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRefNoMatch))
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlExtRefNoMatch))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(0)))
@@ -218,7 +221,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
// verify that one result is returned if the actions are filtered for status code 200
final String rsqlStatusCode = "lastStatusCode==200";
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlStatusCode))
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlStatusCode))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
@@ -227,7 +230,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
// verify no result is returned if we filter for a non-existing status code
final String rsqlWrongStatusCode = "lastStatusCode==999";
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlWrongStatusCode))
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlWrongStatusCode))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(0)))
@@ -247,7 +250,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final String rsqlDsVersion = "distributionSet.version==" + ds.getVersion();
final String rsqlDsId = "distributionSet.id==" + ds.getId();
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsName)
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlDsName)
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -256,25 +259,25 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("content.[0]._links.distributionset.name",
equalTo(ds.getName() + ":" + ds.getVersion())));
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsVersion))
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlDsVersion))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
.andExpect(jsonPath("size", equalTo(1)));
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsName + "," + rsqlDsVersion))
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlDsName + "," + rsqlDsVersion))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
.andExpect(jsonPath("size", equalTo(1)));
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=distributionSet.name==FooBar"))
mvc.perform(get(ACTIONS_V1 + "?q=distributionSet.name==FooBar"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(0)))
.andExpect(jsonPath("size", equalTo(0)));
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsId))
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlDsId))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
@@ -303,7 +306,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final String rsqlRolloutName = "rollout.name==" + rollout.getName();
final String rsqlRolloutId = "rollout.id==" + rollout.getId();
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlRolloutName)
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlRolloutName)
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -313,7 +316,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath(
"content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion())));
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlRolloutId)
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlRolloutId)
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -365,7 +368,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final Action action0 = actions.get(0);
final Action action1 = actions.get(1);
mvc.perform(get(ACTION_V1_REQUEST_MAPPING)
mvc.perform(get(ACTIONS_V1)
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
.andDo(MockMvcResultPrinter.print())
@@ -403,7 +406,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
*/
@Test
void getActionsWithEmptyResult() throws Exception {
mvc.perform(get(ACTION_V1_REQUEST_MAPPING))
mvc.perform(get(ACTIONS_V1))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("size", equalTo(0)))
@@ -421,7 +424,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
// page 1: one entry
final Action action0 = actions.get(0);
mvc.perform(get(ACTION_V1_REQUEST_MAPPING)
mvc.perform(get(ACTIONS_V1)
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1))
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
.andDo(MockMvcResultPrinter.print())
@@ -442,7 +445,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
// page 2: one entry
final Action action1 = actions.get(1);
mvc.perform(get(ACTION_V1_REQUEST_MAPPING)
mvc.perform(get(ACTIONS_V1)
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1))
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))
@@ -473,8 +476,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
// not allowed methods
mvc.perform(post(ACTION_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed());
mvc.perform(put(ACTION_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed());
mvc.perform(post(ACTIONS_V1)).andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed());
mvc.perform(put(ACTIONS_V1)).andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed());
}
/**
@@ -487,7 +490,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
final Long actionId = actions.get(0).getId();
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + actionId))
mvc.perform(get(ACTIONS_V1 + "/" + actionId))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath(JSON_PATH_ACTION_ID, equalTo(actionId.intValue())));
@@ -498,7 +501,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
*/
@Test
void requestActionThatDoesNotExistsLeadsToNotFound() throws Exception {
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + 101)).andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
mvc.perform(get(ACTIONS_V1 + "/" + 101)).andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
}
@Test
@@ -507,18 +510,18 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
Action action1 = assignmentResults.get(0).getAssignedEntity().get(0);
Action action2 = assignmentResults.get(1).getAssignedEntity().get(0);
mvc.perform(get(ACTION_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
mvc.perform(get(ACTIONS_V1).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
// verify action 1
.andExpect(jsonPath("content.[0].id", equalTo(action1.getId().intValue())))
.andExpect(jsonPath("content.[1].id", equalTo(action2.getId().intValue())));
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING + "/" + action1.getId()))
mvc.perform(delete(ACTIONS_V1 + "/" + action1.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + action1.getId()))
mvc.perform(get(ACTIONS_V1 + "/" + action1.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound());
}
@@ -527,7 +530,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
void shouldSuccessfullyDeleteMultipleActions() throws Exception {
final List<DistributionSetAssignmentResult> assignmentResults = createTargetsAndPerformAssignment(4);
mvc.perform(get(ACTION_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
mvc.perform(get(ACTIONS_V1).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
// verify action 1
@@ -542,28 +545,28 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final long deletedActionId2 = assignmentResults.get(3).getAssignedEntity().get(0).getId();
actionIdsToDelete.add(deletedActionId2);
mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
mvc.perform(delete(MgmtActionRestApi.ACTIONS_V1)
.content(toJson(actionIdsToDelete)).contentType(APPLICATION_JSON))
.andExpect(status().isNoContent());
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + deletedActionId1))
mvc.perform(get(ACTIONS_V1 + "/" + deletedActionId1))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound());
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + deletedActionId2))
mvc.perform(get(ACTIONS_V1 + "/" + deletedActionId2))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound());
final Action deletedAction3 = assignmentResults.get(1).getAssignedEntity().get(0);
final String rsql = "target.name==" + deletedAction3.getTarget().getName();
mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
mvc.perform(delete(MgmtActionRestApi.ACTIONS_V1)
.param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, rsql).contentType(APPLICATION_JSON))
.andExpect(status().isNoContent());
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + deletedAction3.getId()))
mvc.perform(get(ACTIONS_V1 + "/" + deletedAction3.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound());
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + assignmentResults.get(0).getAssignedEntity().get(0).getId()))
mvc.perform(get(ACTIONS_V1 + "/" + assignmentResults.get(0).getAssignedEntity().get(0).getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
}
@@ -571,10 +574,10 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
@Test
void shouldReceiveBadRequestWhenNeeded() throws Exception {
// bad request on both empty parameters
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING).contentType(APPLICATION_JSON)).andExpect(status().isBadRequest());
mvc.perform(delete(ACTIONS_V1).contentType(APPLICATION_JSON)).andExpect(status().isBadRequest());
// bad request when both parameters are present
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING).contentType(APPLICATION_JSON)
mvc.perform(delete(ACTIONS_V1).contentType(APPLICATION_JSON)
.param(REQUEST_PARAMETER_SEARCH, "target.name==test")
.content(toJson(List.of(1, 2, 3)))
.contentType(APPLICATION_JSON))
@@ -582,16 +585,16 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
}
private static String generateActionLink(final String targetId, final Long actionId) {
return "http://localhost" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING +
"/" + targetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId;
return "http://localhost" + MgmtTargetRestApi.TARGETS_V1 +
"/" + targetId + "/" + MgmtTarget.TARGET_V1_ACTIONS + "/" + actionId;
}
private static String generateTargetLink(final String targetId) {
return "http://localhost" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + targetId;
return "http://localhost" + MgmtTargetRestApi.TARGETS_V1 + "/" + targetId;
}
private static String generateDistributionSetLink(final Action action) {
return "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + action.getDistributionSet().getId();
return "http://localhost" + MgmtDistributionSetRestApi.DISTRIBUTIONSETS_V1 + "/" + action.getDistributionSet().getId();
}
private List<DistributionSetAssignmentResult> createTargetsAndPerformAssignment(int n) {
@@ -611,7 +614,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
private void verifyResultsByTargetPropertyFilter(final Target target, final DistributionSet ds, final String rsqlTargetFilter)
throws Exception {
// pending status one result
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlTargetFilter)
mvc.perform(get(ACTIONS_V1 + "?q=" + rsqlTargetFilter)
.param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -637,7 +640,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
}
final ResultActions resultActions =
mvc.perform(get(ACTION_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
mvc.perform(get(ACTIONS_V1).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
// verify action 1
@@ -683,7 +686,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
controllerManagement.updateActionExternalRef(actions.get(0).getId(), externalRef);
}
final ResultActions resultActions = mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/{actionId}", actions.get(0).getId()))
final ResultActions resultActions = mvc.perform(get(ACTIONS_V1 + "/{actionId}", actions.get(0).getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());

View File

@@ -19,7 +19,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.util.Base64;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtBasicAuthRestApi;
import org.eclipse.hawkbit.repository.jpa.JpaRepositoryConfiguration;
import org.eclipse.hawkbit.repository.test.TestConfiguration;
import org.eclipse.hawkbit.repository.test.matcher.EventVerifier;
@@ -84,7 +84,7 @@ class MgmtBasicAuthResourceTest {
@Test
@WithUser(principal = TEST_USER, authorities = { "READ", "WRITE", "DELETE" })
void validateBasicAuthWithUserDetails() throws Exception {
withSecurityMock().perform(get(MgmtRestConstants.AUTH_V1_REQUEST_MAPPING))
withSecurityMock().perform(get(MgmtBasicAuthRestApi.USERINFO_V1))
.andDo(MockMvcResultPrinter.print())
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -100,7 +100,7 @@ class MgmtBasicAuthResourceTest {
*/
@Test
void validateBasicAuthFailsWithInvalidCredentials() throws Exception {
defaultMock.perform(get(MgmtRestConstants.AUTH_V1_REQUEST_MAPPING)
defaultMock.perform(get(MgmtBasicAuthRestApi.USERINFO_V1)
.header(HttpHeaders.AUTHORIZATION, getBasicAuth("wrongUser", "wrongSecret")))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isUnauthorized());

View File

@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.mgmt.rest.resource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING;
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi.DISTRIBUTIONSETS_V1;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.hasSize;
@@ -100,7 +100,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
void getSoftwareModules() throws Exception {
// Create DistributionSet with three software modules
final DistributionSet set = testdataFactory.createDistributionSet("SMTest");
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM"))
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/assignedSM"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.size", equalTo(set.getModules().size())));
@@ -114,7 +114,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
final DistributionSet set = testdataFactory.createUpdatedDistributionSet();
// post assignment
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/assignedSM")
.param("offset", "1").param("limit", "2").param("sort", "version:DESC").param("q", "name==one*")
.accept(APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -137,7 +137,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
smList.put(new JSONObject().put("id", smID));
}
// post assignment
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM")
.contentType(APPLICATION_JSON).content(smList.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
@@ -150,7 +150,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
}
assignDistributionSet(disSet.getId(), knownTargetIds[0]);
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedTargets")
.contentType(APPLICATION_JSON).content(list.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -159,7 +159,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.total", equalTo(knownTargetIds.length)));
// try to delete the Software Module from DistSet that has been assigned to the target - hence locked.
mvc.perform(delete(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM/" + smIDs.get(0))
mvc.perform(delete(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM/" + smIDs.get(0))
.contentType(APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isLocked())
@@ -181,7 +181,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
smList.put(new JSONObject().put("id", smID));
}
// post assignment
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM")
.contentType(APPLICATION_JSON).content(smList.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
@@ -191,7 +191,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
final JSONArray list = createTargetAndJsonArray(null, null, null, null, null, knownTargetIds);
// assign DisSet to target and test assignment
assignDistributionSet(disSet.getId(), knownTargetIds[0]);
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedTargets")
.contentType(APPLICATION_JSON).content(list.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -205,7 +205,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
smList2.put(new JSONObject().put("id", sm2.getId()));
// fail because locked
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM")
.contentType(APPLICATION_JSON).content(smList2.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isLocked())
@@ -220,7 +220,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// create DisSet
final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Jupiter", "398,88");
// Test if size is 0
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM"))
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.size", equalTo(disSet.getModules().size())));
@@ -229,12 +229,12 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
testdataFactory.createSoftwareModuleApp().getId());
// post assignment
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM")
.contentType(APPLICATION_JSON).content(toJson(smIDs.stream().map(MgmtId::new).toList())))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
// Test if size is 3
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM"))
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.size", equalTo(smIDs.size())));
@@ -248,18 +248,18 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// post assignment
final String jsonIDs = toJson(moduleIDs.subList(0, maxSoftwareModules - smIDs.size()).stream().map(MgmtId::new).toList());
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM")
.contentType(APPLICATION_JSON).content(jsonIDs))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
// test if size corresponds with quota
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM?limit={limit}", maxSoftwareModules * 2))
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM?limit={limit}", maxSoftwareModules * 2))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.size", equalTo(maxSoftwareModules)));
// post one more to cause the quota to be exceeded
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet.getId() + "/assignedSM")
.contentType(APPLICATION_JSON)
.content(toJson(Stream.of(moduleIDs.get(moduleIDs.size() - 1)).map(MgmtId::new).toList())))
.andDo(MockMvcResultPrinter.print())
@@ -269,7 +269,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// verify quota is also enforced for bulk uploads
final DistributionSet disSet2 = testdataFactory.createDistributionSetWithNoSoftwareModules("Saturn", "4.0");
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet2.getId() + "/assignedSM")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + disSet2.getId() + "/assignedSM")
.contentType(APPLICATION_JSON).content(toJson(moduleIDs.stream().map(MgmtId::new).toList())))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isTooManyRequests())
@@ -277,7 +277,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey())));
// verify size is still 0
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet2.getId() + "/assignedSM"))
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + disSet2.getId() + "/assignedSM"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.size", equalTo(0)));
@@ -291,16 +291,16 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// Create DistributionSet with three software modules
final DistributionSet set = testdataFactory.createDistributionSet("Venus");
int amountOfSM = set.getModules().size();
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM"))
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/assignedSM"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.size", equalTo(amountOfSM)));
// test the removal of all software modules one by one
for (final SoftwareModule softwareModule : set.getModules()) {
final Long smId = softwareModule.getId();
mvc.perform(delete(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM/" + smId))
mvc.perform(delete(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/assignedSM/" + smId))
.andExpect(status().isNoContent());
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM"))
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/assignedSM"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.size", equalTo(--amountOfSM)));
@@ -320,7 +320,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// assign already one target to DS
assignDistributionSet(createdDs.getId(), knownTargetIds[0]);
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets")
.contentType(APPLICATION_JSON).content(list.toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1)))
@@ -349,7 +349,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
list.put(new JSONObject().put("id", targetId).put("type", "forced"));
}
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets")
.contentType(APPLICATION_JSON).content(list.toString()))
.andExpect(status().isOk());
// we just need to make sure that no error 500 is returned
@@ -413,7 +413,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
}
});
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + ds.getId() + "/assignedTargets")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + ds.getId() + "/assignedTargets")
.contentType(APPLICATION_JSON).content(payload.toString()))
.andExpect(status().isTooManyRequests());
@@ -442,7 +442,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// assign our test target to another distribution set and verify that
// the 'max actions per target' quota is exceeded
final String json = new JSONArray().put(new JSONObject().put("id", testTarget.getControllerId())).toString();
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + ds3.getId() + "/assignedTargets")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + ds3.getId() + "/assignedTargets")
.contentType(APPLICATION_JSON).content(json))
.andExpect(status().isTooManyRequests());
}
@@ -466,7 +466,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// assign already one target to DS
assignDistributionSet(createdDs.getId(), targets.get(0).getControllerId());
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId()
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId()
+ "/assignedTargets?offline=true").contentType(APPLICATION_JSON).content(list.toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$.assigned", equalTo(targets.size() - 1)))
@@ -492,7 +492,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// assign already one target to DS
assignDistributionSet(createdDs.getId(), knownTargetIds[0]);
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets")
.contentType(APPLICATION_JSON).content(list.toString()))
.andExpect(status().isBadRequest());
}
@@ -510,7 +510,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// assign already one target to DS
assignDistributionSet(createdDs.getId(), knownTargetIds[0]);
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets")
.contentType(APPLICATION_JSON).content(list.toString()))
.andExpect(status().isBadRequest());
}
@@ -529,7 +529,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// assign already one target to DS
assignDistributionSet(createdDs.getId(), knownTargetIds[0]);
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets")
.contentType(APPLICATION_JSON).content(list.toString()))
.andExpect(status().isOk());
}
@@ -548,7 +548,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// assign already one target to DS
assignDistributionSet(createdDs.getId(), knownTargetIds[0]);
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets")
.contentType(APPLICATION_JSON).content(list.toString()))
.andExpect(status().isBadRequest());
}
@@ -576,7 +576,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// assign already one target to DS
assignDistributionSet(createdDs.getId(), knownTargetIds[0]);
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets")
.contentType(APPLICATION_JSON).content(list.toString()))
.andExpect(status().isOk());
}
@@ -594,7 +594,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assignTargetJson.put(new JSONObject().put("id", "notexistingtarget").put("type", "forced"));
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")
mvc.perform(post(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets")
.contentType(APPLICATION_JSON).content(assignTargetJson.toString()))
.andExpect(status().isOk())
.andExpect(jsonPath("$.alreadyAssigned", equalTo(1)))
@@ -613,7 +613,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
testdataFactory.createTarget(knownTargetId);
assignDistributionSet(createdDs.getId(), knownTargetId);
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets"))
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.size", equalTo(1)))
.andExpect(jsonPath("$.content[0].controllerId", equalTo(knownTargetId)));
@@ -629,7 +629,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assignDistributionSet(set, testdataFactory.createTargets(5, "targetMisc", "Test targets for query"))
.getAssignedEntity();
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedTargets")
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/assignedTargets")
.param("offset", "1").param("limit", "2").param("sort", "name:DESC")
.param("q", "controllerId==target*").accept(APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -644,7 +644,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
@Test
void getAssignedTargetsOfDistributionSetIsEmpty() throws Exception {
final DistributionSet createdDs = testdataFactory.createDistributionSet();
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets"))
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.size", equalTo(0)))
.andExpect(jsonPath("$.total", equalTo(0)));
@@ -668,7 +668,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
testdataFactory.sendUpdateActionStatusToTargets(Collections.singletonList(createTarget), Status.FINISHED,
Collections.singletonList("some message"));
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/installedTargets"))
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/installedTargets"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.size", equalTo(1)))
.andExpect(jsonPath("$.content[0].controllerId", equalTo(knownTargetId)));
@@ -686,7 +686,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.map(Action::getTarget).toList();
testdataFactory.sendUpdateActionStatusToTargets(targets, Status.FINISHED, "some message");
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/installedTargets")
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/installedTargets")
.param("offset", "1").param("limit", "2").param("sort", "name:DESC")
.param("q", "controllerId==target*").accept(APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -710,7 +710,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
targetFilterQueryManagement.create(Create.builder().name("b").query("name==y").build());
targetFilterQueryManagement.create(Create.builder().name("c").query("name==y").build());
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/autoAssignTargetFilters"))
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/autoAssignTargetFilters"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.size", equalTo(1)))
.andExpect(jsonPath("$.content[0].name", equalTo(knownFilterName)));
@@ -724,7 +724,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
final DistributionSet set = testdataFactory.createUpdatedDistributionSet();
targetFilterQueryManagement.create(Create.builder().name("filter1").query("name==a").autoAssignDistributionSet(set).build());
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/autoAssignTargetFilters")
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + set.getId() + "/autoAssignTargetFilters")
.param("offset", "1").param("limit", "2").param("sort", "name:DESC").param("q", "name==*1")
.accept(APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -741,7 +741,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
final DistributionSet createdDs = testdataFactory.createDistributionSet();
final String invalidQuery = "unknownField=le=42";
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/autoAssignTargetFilters")
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/autoAssignTargetFilters")
.param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, invalidQuery))
.andExpect(status().isBadRequest());
}
@@ -757,7 +757,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
prepareTestFilters(filterNamePrefix, createdDs);
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/autoAssignTargetFilters")
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/autoAssignTargetFilters")
.param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, query))
.andExpect(status().isOk())
.andExpect(jsonPath("$.size", equalTo(2)))
@@ -776,7 +776,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
prepareTestFilters(filterNamePrefix, createdDs);
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/autoAssignTargetFilters")
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/autoAssignTargetFilters")
.param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, query))
.andExpect(status().isOk())
.andExpect(jsonPath("$.size", equalTo(0)));
@@ -789,7 +789,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
void getDistributionSetsWithoutAdditionalRequestParameters() throws Exception {
final int sets = 5;
createDistributionSetsAlphabetical(sets);
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING))
mvc.perform(get(DISTRIBUTIONSETS_V1))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets)))
@@ -805,7 +805,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
final int sets = 5;
final int limitSize = 1;
createDistributionSetsAlphabetical(sets);
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING).param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize)))
mvc.perform(get(DISTRIBUTIONSETS_V1).param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize)))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets)))
@@ -822,7 +822,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
final int offsetParam = 2;
final int expectedSize = sets - offsetParam;
createDistributionSetsAlphabetical(sets);
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING)
mvc.perform(get(DISTRIBUTIONSETS_V1)
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam))
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(sets)))
.andDo(MockMvcResultPrinter.print())
@@ -1296,7 +1296,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
distributionSetManagement.createMetadata(testDS.getId(), Map.of(knownKeyPrefix + index, knownValuePrefix + index));
}
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata", testDS.getId()))
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{distributionSetId}/metadata", testDS.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(content().contentType(MediaTypes.HAL_JSON));
@@ -1377,7 +1377,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
final String rsqlFindTargetId1 = "controllerId==1";
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets?q=" + rsqlFindTargetId1)
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/" + createdDs.getId() + "/assignedTargets?q=" + rsqlFindTargetId1)
.contentType(APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("total", equalTo(1)))
@@ -1553,7 +1553,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
rolloutManagement.start(rollout.getId());
rolloutHandler.handleAll();
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics/rollouts", ds1.getId()).contentType(
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics/rollouts", ds1.getId()).contentType(
APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -1563,7 +1563,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("actions").doesNotExist())
.andExpect(jsonPath("totalAutoAssignments").doesNotExist());
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics/rollouts", ds2.getId())
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics/rollouts", ds2.getId())
.contentType(APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -1587,7 +1587,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
rolloutManagement.start(rollout.getId());
rolloutHandler.handleAll();
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics/actions", ds1.getId())
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics/actions", ds1.getId())
.contentType(APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -1596,7 +1596,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("rollouts").doesNotExist())
.andExpect(jsonPath("totalAutoAssignments").doesNotExist());
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics/actions", ds2.getId())
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics/actions", ds2.getId())
.contentType(APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -1620,7 +1620,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
targetFilterQueryManagement.create(
Create.builder().name("test filter 2").autoAssignDistributionSet(ds1).query("name==targets*").build());
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics/autoassignments", ds1.getId()).contentType(
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics/autoassignments", ds1.getId()).contentType(
APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -1628,7 +1628,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("rollouts").doesNotExist())
.andExpect(jsonPath("actions").doesNotExist());
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics/autoassignments", ds2.getId()).contentType(
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics/autoassignments", ds2.getId()).contentType(
APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -1654,7 +1654,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
rolloutManagement.start(rollout.getId());
rolloutHandler.handleAll();
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics", ds1.getId())
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics", ds1.getId())
.contentType(APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -1664,7 +1664,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("rollouts.RUNNING", equalTo(1)))
.andExpect(jsonPath("rollouts.total", equalTo(1)));
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{ds}/statistics/autoassignments", ds2.getId())
mvc.perform(get(DISTRIBUTIONSETS_V1 + "/{ds}/statistics/autoassignments", ds2.getId())
.contentType(APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())

View File

@@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.resource.util.ResourceUtility;
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
@@ -52,7 +53,7 @@ import org.springframework.test.web.servlet.ResultActions;
*/
class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegrationTest {
private static final String DISTRIBUTIONSETTAGS_ROOT = "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/";
private static final String DISTRIBUTIONSETTAGS_ROOT = "http://localhost" + MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/";
/**
* Verifies that a paged result list of DS tags reflects the content on the repository side.
@@ -64,7 +65,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
final DistributionSetTag assigned = tags.get(0);
final DistributionSetTag unassigned = tags.get(1);
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON))
mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
@@ -83,7 +84,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
@Test
void getDistributionSetTagsWithParameters() throws Exception {
testdataFactory.createDistributionSetTags(2);
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==DsTag"))
mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "?limit=10&sort=name:ASC&offset=0&q=name==DsTag"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
}
@@ -102,7 +103,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
distributionSetManagement.assignTag(List.of(distributionSet1.getId(), distributionSet2.getId()), tag1.getId());
distributionSetManagement.assignTag(List.of(distributionSet1.getId()), tag2.getId());
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING)
mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1)
.queryParam(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "distributionset.id==" + distributionSet1.getId())
.accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -116,7 +117,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(2)))
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(2)));
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING)
mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1)
.queryParam(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "distributionset.id==" + distributionSet2.getId())
.accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -145,7 +146,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
// pass here q directly as a pure string because .queryParam method delimiters the parameters in q with ,
// which is logical OR, we want AND here
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING
mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1
+ "?" + MgmtRestConstants.REQUEST_PARAMETER_SEARCH +
"=distributionset.id==" + distributionSet1.getId() + ";description==" + tag1.getDescription())
.accept(MediaType.APPLICATION_JSON))
@@ -168,7 +169,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
final DistributionSetTag assigned = tags.get(0);
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + assigned.getId())
mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + assigned.getId())
.accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -193,7 +194,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.build();
final ResultActions result = mvc
.perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING)
.perform(post(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1)
.content(toJson(List.of(tagOne, tagTwo)))
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -228,7 +229,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.build();
final ResultActions result = mvc
.perform(put(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + original.getId())
.perform(put(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + original.getId())
.content(toJson(update)).contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -255,7 +256,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(1);
final DistributionSetTag original = tags.get(0);
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + original.getId()))
mvc.perform(delete(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + original.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
@@ -276,7 +277,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
final List<DistributionSet> sets = testdataFactory.createDistributionSetsWithoutModules(setsAssigned);
distributionSetManagement.assignTag(sets.stream().map(BaseEntity::getId).toList(), tag.getId());
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned"))
mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(setsAssigned)))
@@ -299,7 +300,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
final List<DistributionSet> sets = testdataFactory.createDistributionSetsWithoutModules(setsAssigned);
distributionSetManagement.assignTag(sets.stream().map(BaseEntity::getId).toList(), tag.getId());
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned")
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize)))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -325,7 +326,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
final List<DistributionSet> sets = testdataFactory.createDistributionSetsWithoutModules(setsAssigned);
distributionSetManagement.assignTag(sets.stream().map(BaseEntity::getId).toList(), tag.getId());
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
mvc.perform(get(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned")
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam))
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(setsAssigned)))
.andDo(MockMvcResultPrinter.print())
@@ -347,7 +348,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
final DistributionSetTag tag = testdataFactory.createDistributionSetTags(1).get(0);
final DistributionSet set = testdataFactory.createDistributionSetsWithoutModules(1).get(0);
mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" +
mvc.perform(post(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned/" +
set.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
@@ -368,7 +369,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
final DistributionSetTag tag = testdataFactory.createDistributionSetTags(1).get(0);
final List<DistributionSet> sets = testdataFactory.createDistributionSetsWithoutModules(2);
mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
mvc.perform(post(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned")
.content(toJson(sets.stream().map(DistributionSet::getId).toList()))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -396,7 +397,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
distributionSetManagement.assignTag(sets.stream().map(BaseEntity::getId).toList(), tag.getId());
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" +
mvc.perform(delete(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned/" +
unassigned.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
@@ -423,7 +424,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
distributionSetManagement.assignTag(sets.stream().map(DistributionSet::getId).toList(), tag.getId());
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
mvc.perform(delete(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned")
.content(toJson(List.of(unassigned0.getId(), unassigned1.getId())))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -459,7 +460,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
withMissing.addAll(missing);
mvc.perform(
post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
post(MgmtDistributionSetTagRestApi.DISTRIBUTIONSETTAGS_V1 + "/" + tag.getId() + "/assigned")
.content(toJson(withMissing))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())

View File

@@ -33,6 +33,7 @@ import com.jayway.jsonpath.JsonPath;
import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssignment;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
@@ -420,7 +421,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
*/
@Test
void getDistributionSetTypesWithParameter() throws Exception {
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING
mvc.perform(get(MgmtDistributionSetTypeRestApi.DISTRIBUTIONSETTYPES_V1
+ "?limit=10&sort=name:ASC&offset=0&q=name==a"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
@@ -528,7 +529,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
.put("colour", "rgb(106,178,83)").toString();
mvc
.perform(put(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}",
.perform(put(MgmtDistributionSetTypeRestApi.DISTRIBUTIONSETTYPES_V1 + "/{distributionSetTypeId}",
testType.getId()).content(body).contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
@@ -560,7 +561,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
// 4 types overall (3 hawkbit tenant default, 1 test default
final int types = 4;
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING))
mvc.perform(get(MgmtDistributionSetTypeRestApi.DISTRIBUTIONSETTYPES_V1))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types)))
@@ -576,7 +577,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
final int types = DEFAULT_DS_TYPES;
final int limitSize = 1;
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING)
mvc.perform(get(MgmtDistributionSetTypeRestApi.DISTRIBUTIONSETTYPES_V1)
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize)))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -593,7 +594,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
final int types = DEFAULT_DS_TYPES;
final int offsetParam = 2;
final int expectedSize = types - offsetParam;
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING)
mvc.perform(get(MgmtDistributionSetTypeRestApi.DISTRIBUTIONSETTYPES_V1)
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam))
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(types)))
.andDo(MockMvcResultPrinter.print())

View File

@@ -38,6 +38,7 @@ import org.awaitility.core.ConditionFactory;
import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutResponseBody;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi;
import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtRestModelMapper;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
@@ -125,7 +126,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
rolloutManagement.approveOrDeny(rollout.getId(), Rollout.ApprovalDecision.APPROVED, "Approved remark.");
mvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", rollout.getId())
mvc.perform(get(MgmtRolloutRestApi.ROLLOUTS_V1 + "/{rolloutId}", rollout.getId())
.accept(MediaTypes.HAL_JSON_VALUE))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -146,7 +147,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
final RolloutGroup firstRolloutGroup = rolloutGroupManagement
.findByRollout(rollout.getId(), PageRequest.of(0, 1)).getContent().get(0);
mvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups/{deployGroupId}/targets",
mvc.perform(get(MgmtRolloutRestApi.ROLLOUTS_V1 + "/{rolloutId}/deploygroups/{deployGroupId}/targets",
rollout.getId(), firstRolloutGroup.getId()).param("offset", "0").param("limit", "2")
.param("sort", "name:ASC").param("q", "controllerId==exampleTarget0")
.accept(MediaTypes.HAL_JSON_VALUE))
@@ -165,7 +166,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
testdataFactory.createTargets(4, "rollout", "description");
final DistributionSet dsA = testdataFactory.createDistributionSet("");
final Rollout rollout = createRollout("rollout1", 3, dsA, "controllerId==rollout*", false);
mvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/approve", rollout.getId())
mvc.perform(post(MgmtRolloutRestApi.ROLLOUTS_V1 + "/{rolloutId}/approve", rollout.getId())
.accept(MediaTypes.HAL_JSON_VALUE))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
@@ -184,7 +185,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
testdataFactory.createTargets(4, "rollout", "description");
final DistributionSet dsA = testdataFactory.createDistributionSet("");
final Rollout rollout = createRollout("rollout1", 3, dsA, "controllerId==rollout*", false);
mvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deny", rollout.getId())
mvc.perform(post(MgmtRolloutRestApi.ROLLOUTS_V1 + "/{rolloutId}/deny", rollout.getId())
.accept(MediaTypes.HAL_JSON_VALUE))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());

View File

@@ -47,6 +47,7 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule;
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi;
import org.eclipse.hawkbit.mgmt.rest.resource.util.ResourceUtility;
import org.eclipse.hawkbit.repository.Constants;
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
@@ -145,7 +146,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(random), null, 0, null, sm.getId(), "file1", false));
mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", sm.getId())
mvc.perform(get(MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1 + "/{softwareModuleId}/artifacts", sm.getId())
.param("representation", MgmtRepresentationMode.FULL.toString())
.param("useartifacturlhandler", Boolean.TRUE.toString()))
.andDo(MockMvcResultPrinter.print())
@@ -167,7 +168,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
softwareModuleManagement.createMetadata(module.getId(), knownKeyPrefix + index, new MetadataValueCreate(knownValuePrefix + index));
}
mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata",
mvc.perform(get(MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1 + "/{softwareModuleId}/metadata",
module.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -188,7 +189,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
softwareModuleManagement.createMetadata(module.getId(), knownKeyPrefix + index, new MetadataValueCreate(knownValuePrefix + index));
}
mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata",
mvc.perform(get(MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1 + "/{softwareModuleId}/metadata",
module.getId()).param("offset", "1").param("limit", "2").param("sort", "key:DESC").param("q",
"key==known*"))
.andDo(MockMvcResultPrinter.print())
@@ -208,7 +209,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
final SoftwareModule module = findFirstModuleByType(testdataFactory.createDistributionSet("one"), osType).orElseThrow();
softwareModuleManagement.createMetadata(module.getId(), knownKey, new MetadataValueCreate(knownValue));
mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}",
mvc.perform(get(MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1 + "/{softwareModuleId}/metadata/{metadataKey}",
module.getId(), knownKey))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
@@ -1056,7 +1057,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
void getSoftwareModulesWithoutAdditionalRequestParameters() throws Exception {
final int modules = 5;
createSoftwareModulesAlphabetical(modules);
mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING))
mvc.perform(get(MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(modules)))
@@ -1072,7 +1073,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
final int modules = 5;
final int limitSize = 1;
createSoftwareModulesAlphabetical(modules);
mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING).param(
mvc.perform(get(MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1).param(
MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize)))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -1090,7 +1091,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
final int offsetParam = 2;
final int expectedSize = modules - offsetParam;
createSoftwareModulesAlphabetical(modules);
mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING).param(
mvc.perform(get(MgmtSoftwareModuleRestApi.SOFTWAREMODULES_V1).param(
MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam))
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(modules)))
.andDo(MockMvcResultPrinter.print())

View File

@@ -28,6 +28,7 @@ import java.util.List;
import com.jayway.jsonpath.JsonPath;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi;
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
import org.eclipse.hawkbit.repository.model.NamedEntity;
@@ -104,7 +105,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
.update(SoftwareModuleTypeManagement.Update.builder().id(testType.getId()).description("Desc1234").colour("rgb(106,178,83)")
.build());
mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==a")
mvc.perform(get(MgmtSoftwareModuleTypeRestApi.SOFTWAREMODULETYPES_V1 + "?limit=10&sort=name:ASC&offset=0&q=name==a")
.accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
@@ -359,7 +360,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
@Test
void getSoftwareModuleTypesWithoutAddtionalRequestParameters() throws Exception {
final int types = 3;
mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING))
mvc.perform(get(MgmtSoftwareModuleTypeRestApi.SOFTWAREMODULETYPES_V1))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types)))
@@ -374,7 +375,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
void getSoftwareModuleTypesWithPagingLimitRequestParameter() throws Exception {
final int types = 3;
final int limitSize = 1;
mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING)
mvc.perform(get(MgmtSoftwareModuleTypeRestApi.SOFTWAREMODULETYPES_V1)
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize)))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -391,7 +392,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
final int types = 3;
final int offsetParam = 2;
final int expectedSize = types - offsetParam;
mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING)
mvc.perform(get(MgmtSoftwareModuleTypeRestApi.SOFTWAREMODULETYPES_V1)
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam))
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(types)))
.andDo(MockMvcResultPrinter.print())

View File

@@ -28,7 +28,9 @@ import java.util.stream.Stream;
import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetFilterQueryRestApi;
import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtRestModelMapper;
import org.eclipse.hawkbit.mgmt.rest.resource.util.ResourceUtility;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
@@ -101,7 +103,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
void getTargetFilterQueries() throws Exception {
final String filterName = "filter_01";
createSingleTargetFilterQuery(filterName, "name==test_01");
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING))
mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1))
.andExpect(status().isOk())
.andDo(MockMvcResultPrinter.print());
}
@@ -111,7 +113,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
*/
@Test
void getTargetFilterQueriesWithParameters() throws Exception {
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==*1"))
mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "?limit=10&sort=name:ASC&offset=0&q=name==*1"))
.andExpect(status().isOk())
.andDo(MockMvcResultPrinter.print());
}
@@ -127,7 +129,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
.put("name", name)
.put("query", filterQuery).toString();
mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING)
mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1)
.contentType(MediaType.APPLICATION_JSON).content(body))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isCreated());
@@ -141,7 +143,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
final String filterName = "filter_01";
final TargetFilterQuery filterQuery = createSingleTargetFilterQuery(filterName, "name==test_01");
mvc.perform(delete(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId()))
mvc.perform(delete(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + filterQuery.getId()))
.andExpect(status().isNoContent());
assertThat(targetFilterQueryManagement.find(filterQuery.getId())).isNotPresent();
@@ -154,7 +156,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
void deleteTargetWhichDoesNotExistsLeadsToEntityNotFound() throws Exception {
final String notExistingId = "4395";
mvc.perform(delete(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + notExistingId))
mvc.perform(delete(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + notExistingId))
.andExpect(status().isNotFound());
}
@@ -164,7 +166,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
@Test
void updateTargetWhichDoesNotExistsLeadsToEntityNotFound() throws Exception {
final String notExistingId = "4395";
mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + notExistingId).content("{}")
mvc.perform(put(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + notExistingId).content("{}")
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isNotFound());
@@ -183,7 +185,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
// prepare
final TargetFilterQuery tfq = createSingleTargetFilterQuery(filterName, filterQuery);
mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId()).content(body)
mvc.perform(put(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId()).content(body)
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isOk())
@@ -210,7 +212,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
// prepare
final TargetFilterQuery tfq = targetFilterQueryManagement.create(Create.builder().name(filterName).query(filterQuery).build());
mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId()).content(body)
mvc.perform(put(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId()).content(body)
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isOk())
@@ -239,7 +241,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
createSingleTargetFilterQuery(idB, testQuery);
createSingleTargetFilterQuery(idC, testQuery);
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING))
mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1))
.andExpect(status().isOk())
.andDo(print())
.andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(knownTargetAmount)))
@@ -272,7 +274,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
createSingleTargetFilterQuery(idB, testQuery);
createSingleTargetFilterQuery(idC, testQuery);
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING)
mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1)
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize)))
.andExpect(status().isOk())
.andDo(print())
@@ -290,25 +292,25 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
final DistributionSet set = testdataFactory.createDistributionSet();
final TargetFilterQuery filterQuery = createSingleTargetFilterQuery("a", testQuery);
final String hrefPrefix = "http://localhost" + MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/"
final String hrefPrefix = "http://localhost" + MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/"
+ filterQuery.getId();
final String distributionsetHrefPrefix = "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING;
final String distributionsetHrefPrefix = "http://localhost" + MgmtDistributionSetRestApi.DISTRIBUTIONSETS_V1;
final String dsQuery = "?q=name==" + set.getName() + ";" + "version==" + set.getVersion() + "&offset=0&limit=50";
mvc.perform(
post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId() + "/autoAssignDS")
post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + filterQuery.getId() + "/autoAssignDS")
.content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isOk());
final String result = mvc.perform(
get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId()))
get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + filterQuery.getId()))
.andExpect(jsonPath("$._links.autoAssignDS.href", equalTo(hrefPrefix + "/autoAssignDS")))
.andExpect(jsonPath("$._links.DS.href", startsWith(distributionsetHrefPrefix)))
.andReturn().getResponse().getContentAsString();
final String multipleResult = mvc.perform(
get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "?representation=full"))
get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "?representation=full"))
.andExpect(jsonPath("$.content", hasSize(1)))
.andExpect(jsonPath("$.total", equalTo(1)))
.andExpect(jsonPath("$.content[0]._links.DS.href", startsWith(distributionsetHrefPrefix)))
@@ -345,7 +347,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
createSingleTargetFilterQuery(idD, testQuery);
createSingleTargetFilterQuery(idE, testQuery);
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING)
mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1)
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam))
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(knownTargetAmount)))
.andExpect(status().isOk())
@@ -373,10 +375,10 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
final String knownQuery = "name==test01";
final String knownName = "someName";
final TargetFilterQuery tfq = createSingleTargetFilterQuery(knownName, knownQuery);
final String hrefPrefix = "http://localhost" + MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/"
final String hrefPrefix = "http://localhost" + MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/"
+ tfq.getId();
// test
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId()))
mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId()))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath(JSON_PATH_NAME, equalTo(knownName)))
@@ -395,7 +397,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
// test
final MvcResult mvcResult = mvc
.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + targetIdNotExists))
.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + targetIdNotExists))
.andExpect(status().isNotFound())
.andReturn();
@@ -413,7 +415,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
final String notJson = "abc";
final MvcResult mvcResult = mvc
.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING).content(notJson)
.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1).content(notJson)
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isBadRequest())
@@ -436,7 +438,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
final String invalidQuery = "name=abc";
final String body = new JSONObject().put("query", invalidQuery).put("name", "invalidFilter").toString();
mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING).content(body)
mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1).content(body)
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isBadRequest())
@@ -461,7 +463,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
final TargetFilterQuery filterQuery = createSingleTargetFilterQuery("1", "controllerId==target*");
mvc.perform(
post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId() + "/autoAssignDS")
post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + filterQuery.getId() + "/autoAssignDS")
.content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isTooManyRequests())
@@ -487,7 +489,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
// assign the auto-assign distribution set, this should work
mvc.perform(
post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId() + "/autoAssignDS")
post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + filterQuery.getId() + "/autoAssignDS")
.content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isOk());
@@ -499,7 +501,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
assertThat(updatedFilterQuery.getAutoAssignActionType()).isEqualTo(ActionType.FORCED);
// update the query of the filter query to trigger a quota hit
mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId())
mvc.perform(put(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + filterQuery.getId())
.content("{\"query\":\"controllerId==target*\"}").contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isTooManyRequests())
@@ -547,7 +549,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
final DistributionSet ds = testdataFactory.createDistributionSet("ds");
targetFilterQueryManagement.updateAutoAssignDS(new AutoAssignDistributionSetUpdate(filterQuery.getId()).ds(ds.getId()));
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS",
mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/{targetFilterQueryId}/autoAssignDS",
filterQuery.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
@@ -568,7 +570,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
.put("type", MgmtActionType.SOFT.getName()).put("weight", 200).toString();
mvc
.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS",
.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/{targetFilterQueryId}/autoAssignDS",
filterQuery.getId()).contentType(MediaType.APPLICATION_JSON).content(autoAssignBody))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
@@ -583,7 +585,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
final TargetFilterQuery filterQuery = createSingleTargetFilterQuery(filterName, "name==test_01");
mvc
.perform(delete(
MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS",
MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/{targetFilterQueryId}/autoAssignDS",
filterQuery.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
@@ -608,11 +610,11 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
assertThat(updatedFilterQuery.getAutoAssignDistributionSet()).isEqualTo(set);
assertThat(updatedFilterQuery.getAutoAssignActionType()).isEqualTo(ActionType.FORCED);
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS"))
mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS"))
.andExpect(status().isOk())
.andExpect(jsonPath(JSON_PATH_NAME, equalTo(dsName)));
mvc.perform(delete(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS"))
mvc.perform(delete(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS"))
.andExpect(status().isNoContent());
final TargetFilterQuery filterQueryWithDeletedDs = targetFilterQueryManagement.find(tfq.getId()).get();
@@ -620,7 +622,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
assertThat(filterQueryWithDeletedDs.getAutoAssignDistributionSet()).isNull();
assertThat(filterQueryWithDeletedDs.getAutoAssignActionType()).isNull();
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS"))
mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS"))
.andExpect(status().isNoContent());
}
@@ -637,17 +639,17 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
.toString();
final String valideWeightRequest = new JSONObject().put("id", dsId).put("weight", 45).toString();
mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS",
mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/{targetFilterQueryId}/autoAssignDS",
filterId).content(valideWeightRequest).contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isOk());
enableMultiAssignments();
mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS",
mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/{targetFilterQueryId}/autoAssignDS",
filterId).content(invalideWeightRequest).contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isBadRequest())
.andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.repo.constraintViolation")));
mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS",
mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/{targetFilterQueryId}/autoAssignDS",
filterId).content(valideWeightRequest).contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isOk());
@@ -702,7 +704,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
private void verifyAutoAssignmentByActionType(final TargetFilterQuery tfq, final DistributionSet set,
final MgmtActionType actionType, final Boolean confirmationRequired) throws Exception {
final String hrefPrefix = "http://localhost" + MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/"
final String hrefPrefix = "http://localhost" + MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/"
+ tfq.getId();
final JSONObject jsonObject = new JSONObject();
@@ -714,7 +716,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
jsonObject.put("confirmationRequired", confirmationRequired);
}
mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS")
mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS")
.content(jsonObject.toString()).contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isOk());
@@ -727,7 +729,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
assertThat(updatedFilterQuery.getAutoAssignActionType())
.isEqualTo(MgmtRestModelMapper.convertActionType(expectedActionType));
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId()))
mvc.perform(get(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId()))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath(JSON_PATH_NAME, equalTo(tfq.getName())))
@@ -744,7 +746,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
private void verifyAutoAssignmentWithTimeForcedActionType(final TargetFilterQuery tfq, final DistributionSet set)
throws Exception {
mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS")
mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS")
.content("{\"id\":" + set.getId() + ", \"type\":\"" + MgmtActionType.TIMEFORCED.getName() + "\"}")
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())
@@ -762,7 +764,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
private void verifyAutoAssignmentWithUnknownActionType(final TargetFilterQuery tfq, final DistributionSet set)
throws Exception {
mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS")
mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS")
.content("{\"id\":" + set.getId() + ", \"type\":\"unknown\"}").contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isBadRequest())
@@ -777,7 +779,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
.name("incomplete").version("1")
.build());
mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS")
mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS")
.content("{\"id\":" + incompleteDistributionSet.getId() + "}").contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isBadRequest())
@@ -791,7 +793,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
assignDistributionSet(softDeletedDs, testdataFactory.createTarget("forSoftDeletedDs"));
distributionSetManagement.delete(softDeletedDs.getId());
mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS")
mvc.perform(post(MgmtTargetFilterQueryRestApi.TARGETFILTERS_V1 + "/" + tfq.getId() + "/autoAssignDS")
.content("{\"id\":" + softDeletedDs.getId() + "}").contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isNotFound())

View File

@@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.List;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetGroupRestApi;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
@@ -35,7 +36,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
targetManagement.create(builder().controllerId("target2").group("Asia").build());
targetManagement.create(builder().controllerId("target3").group("Europe").build());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING)
mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.[0]", Matchers.in(expectedGroups)))
@@ -48,14 +49,14 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
targetManagement.create(builder().controllerId("target2").group("Europe/East").build());
targetManagement.create(builder().controllerId("target3").group("Europe").build());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned")
.param("group", "Europe/East")
.param("subgroups", "false"))
.andExpect(status().isOk())
.andExpect(jsonPath("content", Matchers.hasSize(1)))
.andExpect(jsonPath("content.[0].controllerId", Matchers.equalTo("target2")));
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned")
.param("group", "Europe")
.param("subgroups", "true")
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
@@ -72,7 +73,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
targetManagement.create(builder().controllerId("target2").group("US").build());
targetManagement.create(builder().controllerId("target3").group("Europe").build());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/Europe/assigned")
mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/Europe/assigned")
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
.andExpect(status().isOk())
.andExpect(jsonPath("content", Matchers.hasSize(2)))
@@ -86,12 +87,12 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
targetManagement.create(builder().controllerId("target2").build());
targetManagement.create(builder().controllerId("target3").group("Europe").build());
mvc.perform(put(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/newGroup/assigned")
mvc.perform(put(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/newGroup/assigned")
.contentType(MediaType.APPLICATION_JSON)
.content(toJson(Arrays.asList("target1", "target2", "target3"))))
.andExpect(status().isNoContent());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/newGroup/assigned")
mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/newGroup/assigned")
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
@@ -103,7 +104,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
@Test
void shouldReturnBadRequestWhenProvidingAnEmptyListOfControllerIds() throws Exception {
mvc.perform(put(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/someGroup/assigned")
mvc.perform(put(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/someGroup/assigned")
.contentType(MediaType.APPLICATION_JSON)
.content(toJson(Collections.emptyList())))
.andExpect(status().isBadRequest());
@@ -115,13 +116,13 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
targetManagement.create(builder().controllerId("target2").build());
targetManagement.create(builder().controllerId("target3").group("US").build());
mvc.perform(put(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
mvc.perform(put(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned")
.contentType(MediaType.APPLICATION_JSON)
.content(toJson(Arrays.asList("target1", "target2", "target3")))
.param("group", "Europe/East"))
.andExpect(status().isNoContent());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned")
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")
.param("group", "Europe/East")
.contentType(MediaType.APPLICATION_JSON))
@@ -132,7 +133,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
.andExpect(jsonPath("content.[2].controllerId", Matchers.equalTo("target3")));
// expect bad request if empty controllerIds
mvc.perform(put(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
mvc.perform(put(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned")
.contentType(MediaType.APPLICATION_JSON)
.content(toJson(Collections.emptyList()))
.param("group", "doesNotMatter"))
@@ -145,12 +146,12 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
targetManagement.create(builder().controllerId("target2").build());
targetManagement.create(builder().controllerId("shouldNotAssign").group("B").build());
mvc.perform(put(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/C")
mvc.perform(put(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/C")
.contentType(MediaType.APPLICATION_JSON)
.param("q", "controllerId==target*"))
.andExpect(status().isNoContent());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned")
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")
.param("group", "C")
.contentType(MediaType.APPLICATION_JSON))
@@ -165,12 +166,12 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
targetManagement.create(builder().controllerId("target1").group("Europe").build());
targetManagement.create(builder().controllerId("target2").group("Europe").build());
mvc.perform(delete(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
mvc.perform(delete(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned")
.contentType(MediaType.APPLICATION_JSON)
.content(toJson(Arrays.asList("target1", "target2"))))
.andExpect(status().isNoContent());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned")
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")
.param("group", "Europe")
.contentType(MediaType.APPLICATION_JSON))
@@ -178,7 +179,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
.andExpect(jsonPath("content", Matchers.hasSize(0)));
// expect bad request if empty
mvc.perform(delete(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
mvc.perform(delete(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned")
.contentType(MediaType.APPLICATION_JSON)
.content(toJson(Collections.emptyList())))
.andExpect(status().isBadRequest());
@@ -190,12 +191,12 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
targetManagement.create(builder().controllerId("target2").group("Europe").build());
targetManagement.create(builder().controllerId("nonMatchingTarget").group("Europe").build());
mvc.perform(delete(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING)
mvc.perform(delete(MgmtTargetGroupRestApi.TARGETGROUPS_V1)
.contentType(MediaType.APPLICATION_JSON)
.param("q", "controllerId==target*"))
.andExpect(status().isNoContent());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned")
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")
.param("group", "Europe")
.contentType(MediaType.APPLICATION_JSON))
@@ -212,13 +213,13 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
targetManagement.create(builder().controllerId("shouldNotBeUpdated1").group("Europe").build());
targetManagement.create(builder().controllerId("shouldNotBeUpdated2").group("Europe").build());
mvc.perform(put(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING)
mvc.perform(put(MgmtTargetGroupRestApi.TARGETGROUPS_V1)
.contentType(MediaType.APPLICATION_JSON)
.param("group", "Europe/East")
.param("q", "controllerId==target*"))
.andExpect(status().isNoContent());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
mvc.perform(get(MgmtTargetGroupRestApi.TARGETGROUPS_V1 + "/assigned")
.param("group", "Europe/East")
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")
.contentType(MediaType.APPLICATION_JSON))

View File

@@ -55,7 +55,7 @@ import org.springframework.test.web.servlet.ResultActions;
*/
public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationTest {
private static final String TARGETTAGS_ROOT = "http://localhost" + MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/";
private static final String TARGETTAGS_ROOT = "http://localhost" + MgmtTargetTagRestApi.TARGETTAGS_V1 + "/";
/**
* Verifies that a paged result list of target tags reflects the content on the repository side.
@@ -67,7 +67,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final TargetTag assigned = tags.get(0);
final TargetTag unassigned = tags.get(1);
mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON))
mvc.perform(get(MgmtTargetTagRestApi.TARGETTAGS_V1).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
@@ -87,7 +87,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
@Test
void getTargetTagsWithParameters() throws Exception {
testdataFactory.createTargetTags(2, "");
mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==targetTag"))
mvc.perform(get(MgmtTargetTagRestApi.TARGETTAGS_V1 + "?limit=10&sort=name:ASC&offset=0&q=name==targetTag"))
.andExpect(status().isOk())
.andDo(MockMvcResultPrinter.print());
}
@@ -111,7 +111,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
// pass here q directly as a pure string because .queryParam method delimiters the parameters in q with ,
// which is logical OR, we want AND here
mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING +
mvc.perform(get(MgmtTargetTagRestApi.TARGETTAGS_V1 +
"?" + MgmtRestConstants.REQUEST_PARAMETER_SEARCH + "=colour==" + tag2.getColour())
.accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -133,7 +133,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final List<? extends TargetTag> tags = testdataFactory.createTargetTags(2, "");
final TargetTag assigned = tags.get(0);
mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + assigned.getId())
mvc.perform(get(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + assigned.getId())
.accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -159,7 +159,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.build();
final ResultActions result = mvc
.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING)
.perform(post(MgmtTargetTagRestApi.TARGETTAGS_V1)
.content(toJson(List.of(tagOne, tagTwo)))
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -194,7 +194,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.build();
final ResultActions result = mvc
.perform(put(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + original.getId())
.perform(put(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + original.getId())
.content(toJson(update)).contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -221,7 +221,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final List<? extends TargetTag> tags = testdataFactory.createTargetTags(1, "");
final TargetTag original = tags.get(0);
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + original.getId()))
mvc.perform(delete(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + original.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
@@ -242,7 +242,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final List<Target> targets = testdataFactory.createTargets(targetsAssigned);
targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId());
mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned"))
mvc.perform(get(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(targetsAssigned)))
@@ -265,7 +265,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final List<Target> targets = testdataFactory.createTargets(targetsAssigned);
targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId());
mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
mvc.perform(get(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned")
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize)))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -291,7 +291,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final List<Target> targets = testdataFactory.createTargets(targetsAssigned);
targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId());
mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
mvc.perform(get(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned")
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam))
.param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(targetsAssigned)))
.andDo(MockMvcResultPrinter.print())
@@ -313,7 +313,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final TargetTag tag = testdataFactory.createTargetTags(1, "").get(0);
final Target assigned = testdataFactory.createTargets(1).get(0);
mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" +
mvc.perform(post(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned/" +
assigned.getControllerId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
@@ -336,7 +336,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final Target assigned0 = targets.get(0);
final Target assigned1 = targets.get(1);
mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
mvc.perform(post(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned")
.content(toJson(List.of(assigned0.getControllerId(), assigned1.getControllerId())))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -371,7 +371,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final List<String> withMissing = new ArrayList<>(targets);
withMissing.addAll(missing);
mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
mvc.perform(post(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned")
.content(toJson(withMissing))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -413,7 +413,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final List<String> withMissing = new ArrayList<>(targets);
withMissing.addAll(missing);
mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
mvc.perform(post(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned")
.param("onNotFoundPolicy", MgmtTargetTagRestApi.OnNotFoundPolicy.ON_WHAT_FOUND_AND_FAIL.name())
.content(toJson(withMissing))
.contentType(MediaType.APPLICATION_JSON))
@@ -457,7 +457,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final List<String> withMissing = new ArrayList<>(targets);
withMissing.addAll(missing);
mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
mvc.perform(post(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned")
.param("onNotFoundPolicy", MgmtTargetTagRestApi.OnNotFoundPolicy.ON_WHAT_FOUND_AND_SUCCESS.name())
.content(toJson(withMissing))
.contentType(MediaType.APPLICATION_JSON))
@@ -483,7 +483,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId());
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" +
mvc.perform(delete(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned/" +
unassigned.getControllerId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
@@ -510,7 +510,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
targetManagement.assignTag(targets.stream().map(Target::getControllerId).toList(), tag.getId());
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
mvc.perform(delete(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned")
.content(toJson(Arrays.asList(unassigned0.getControllerId(), unassigned1.getControllerId())))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -548,7 +548,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
targetManagement.assignTag(targets, tag.getId());
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
mvc.perform(delete(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned")
.content(toJson(withMissing))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -593,7 +593,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
targetManagement.assignTag(targets, tag.getId());
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
mvc.perform(delete(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned")
.param("onNotFoundPolicy", MgmtTargetTagRestApi.OnNotFoundPolicy.ON_WHAT_FOUND_AND_FAIL.name())
.content(toJson(withMissing))
.contentType(MediaType.APPLICATION_JSON))
@@ -638,7 +638,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
targetManagement.assignTag(targets, tag.getId());
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")
mvc.perform(delete(MgmtTargetTagRestApi.TARGETTAGS_V1 + "/" + tag.getId() + "/assigned")
.param("onNotFoundPolicy", MgmtTargetTagRestApi.OnNotFoundPolicy.ON_WHAT_FOUND_AND_SUCCESS.name())
.content(toJson(withMissing))
.contentType(MediaType.APPLICATION_JSON))

View File

@@ -33,7 +33,9 @@ import com.jayway.jsonpath.JsonPath;
import org.eclipse.hawkbit.auth.SpPermission;
import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.mgmt.json.model.MgmtId;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTypeRestApi;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.TargetTypeManagement.Create;
import org.eclipse.hawkbit.repository.TargetTypeManagement.Update;
@@ -57,9 +59,9 @@ import org.springframework.test.web.servlet.ResultActions;
*/
class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
private static final String TARGETTYPES_ENDPOINT = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING;
private static final String TARGETTYPE_SINGLE_ENDPOINT = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{typeid}";
private static final String TARGETTYPE_DSTYPES_ENDPOINT = TARGETTYPE_SINGLE_ENDPOINT + "/" + MgmtRestConstants.COMPATIBLEDISTRIBUTIONSETTYPES;
private static final String TARGETTYPES_ENDPOINT = MgmtTargetTypeRestApi.TARGETTYPES_V1;
private static final String TARGETTYPE_SINGLE_ENDPOINT = MgmtTargetTypeRestApi.TARGETTYPES_V1 + "/{typeid}";
private static final String TARGETTYPE_DSTYPES_ENDPOINT = TARGETTYPE_SINGLE_ENDPOINT + "/" + MgmtTargetTypeRestApi.COMPATIBLEDISTRIBUTIONSETTYPES;
private static final String TARGETTYPE_DSTYPE_SINGLE_ENDPOINT = TARGETTYPE_DSTYPES_ENDPOINT + "/{dstypeid}";
private static final String TEST_USER = "targetTypeTester";
@@ -423,7 +425,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
assertThat(testType.getDistributionSetTypes()).hasSize(1);
assertThat(distributionSetTypeManagement.findByKey(standardDsType.getKey())).isNotEmpty();
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/" + standardDsType.getId()))
mvc.perform(delete(MgmtDistributionSetTypeRestApi.DISTRIBUTIONSETTYPES_V1 + "/" + standardDsType.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());

View File

@@ -9,7 +9,7 @@
*/
package org.eclipse.hawkbit.mgmt.rest.resource;
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING;
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtTenantManagementRestApi.SYSTEM_V1;
import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.callAs;
import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.getAs;
import static org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch.withUser;
@@ -52,7 +52,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
*/
@Test
void getTenantConfigurations() throws Exception {
mvc.perform(get(SYSTEM_V1_REQUEST_MAPPING + "/configs"))
mvc.perform(get(SYSTEM_V1 + "/configs"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
// check for TenantMetadata additional properties
@@ -66,7 +66,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
@Test
void getTenantConfiguration() throws Exception {
// test TenantConfiguration property
mvc.perform(get(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY))
mvc.perform(get(SYSTEM_V1 + "/configs/{keyName}", AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
}
@@ -77,7 +77,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
@Test
void getTenantMetadata() throws Exception {
// test TenantMetadata property
mvc.perform(get(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY))
mvc.perform(get(SYSTEM_V1 + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(jsonPath("$.value", equalTo(getActualDefaultDsType().intValue())));
@@ -93,7 +93,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
final ObjectMapper mapper = new ObjectMapper();
final String json = mapper.writeValueAsString(bodyPut);
mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY)
mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY)
.contentType(MediaType.APPLICATION_JSON)
.content(json))
.andDo(MockMvcResultPrinter.print())
@@ -113,7 +113,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
final ObjectMapper mapper = new ObjectMapper();
final String json = mapper.writeValueAsString(bodyPut);
mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY)
mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY)
.contentType(MediaType.APPLICATION_JSON)
.content(json))
.andDo(MockMvcResultPrinter.print())
@@ -149,13 +149,13 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
final String bodyActivate = new JSONObject().put("value", true).toString();
final String bodyDeactivate = new JSONObject().put("value", false).toString();
mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", MULTI_ASSIGNMENTS_ENABLED)
mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", MULTI_ASSIGNMENTS_ENABLED)
.content(bodyActivate)
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", MULTI_ASSIGNMENTS_ENABLED)
mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", MULTI_ASSIGNMENTS_ENABLED)
.content(bodyDeactivate)
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -232,7 +232,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
final String body = configuration.toString();
mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs").content(body).contentType(MediaType.APPLICATION_JSON))
mvc.perform(put(SYSTEM_V1 + "/configs").content(body).contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
@@ -258,21 +258,21 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
final String bodyDeactivate = new JSONObject().put("value", false).toString();
// enable Multi-Assignments
mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", MULTI_ASSIGNMENTS_ENABLED)
mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", MULTI_ASSIGNMENTS_ENABLED)
.content(bodyActivate)
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
// try to enable Auto-Close
mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED)
mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED)
.content(bodyActivate)
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isForbidden());
// try to disable Auto-Close
mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED)
mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED)
.content(bodyDeactivate)
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -284,7 +284,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
*/
@Test
void deleteTenantConfiguration() throws Exception {
mvc.perform(delete(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY))
mvc.perform(delete(SYSTEM_V1 + "/configs/{keyName}", AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNoContent());
}
@@ -294,7 +294,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
*/
@Test
void deleteTenantMetadataFail() throws Exception {
mvc.perform(delete(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY))
mvc.perform(delete(SYSTEM_V1 + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound());
}
@@ -312,7 +312,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
// TODO - should be able to read with TENANT_CONFIGURATION but somehow here the role hierarchy doesn't play
// checked in mgmt / update server runtime PreAuthorizeEnabledTest
callAs(withUser("tenant_admin", SpPermission.READ_TENANT_CONFIGURATION, SpPermission.READ_GATEWAY_SECURITY_TOKEN), () -> {
mvc.perform(get(SYSTEM_V1_REQUEST_MAPPING + "/configs"))
mvc.perform(get(SYSTEM_V1 + "/configs"))
.andDo(MockMvcResultPrinter.print())
.andDo(m -> System.out.println("-> 1: " + m.getResponse().getContentAsString()))
.andExpect(status().isOk())
@@ -322,7 +322,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
});
callAs(withUser("tenant_read", SpPermission.READ_TENANT_CONFIGURATION), () -> {
mvc.perform(get(SYSTEM_V1_REQUEST_MAPPING + "/configs"))
mvc.perform(get(SYSTEM_V1 + "/configs"))
.andDo(MockMvcResultPrinter.print())
.andDo(m -> System.out.println("-> 2: " + m.getResponse().getContentAsString()))
.andExpect(status().isOk())
@@ -342,7 +342,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
private void assertDefaultDsTypeUpdateBadRequestFails(
final String newDefaultDsType, final long oldDefaultDsType, final ResultMatcher resultMatchers)
throws Exception {
mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY)
mvc.perform(put(SYSTEM_V1 + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY)
.content(newDefaultDsType)
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
@@ -369,7 +369,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
configuration.put(DEFAULT_DISTRIBUTION_SET_TYPE_KEY, newDistributionSetTypeId);
String body = configuration.toString();
mvc.perform(put(SYSTEM_V1_REQUEST_MAPPING + "/configs").content(body).contentType(MediaType.APPLICATION_JSON))
mvc.perform(put(SYSTEM_V1 + "/configs").content(body).contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(resultMatchers);
//Check if TenantMetadata and TenantConfiguration is not changed as Batch config failed