Allign MGMT Rest APIs -> return 204 NO_CONTENT w/o body where success… (#2793)

* Allign MGMT Rest APIs -> return 204 NO_CONTENT w/o body where success w/o body is intended

# Conflicts:
#	hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java

* Fix File download wrong no_content, Fix Tests

* Fix ApiResponses where missed 200->204

---------

Co-authored-by: vasilchev <vasil.ilchev@bosch.com>
This commit is contained in:
Vasil Ilchev
2025-11-17 12:53:44 +02:00
committed by GitHub
parent 1268d12495
commit 76a77f85e2
39 changed files with 228 additions and 230 deletions

View File

@@ -516,7 +516,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING + "/" + action1.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + action1.getId()))
.andDo(MockMvcResultPrinter.print())
@@ -542,8 +542,9 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final long deletedActionId2 = assignmentResults.get(3).getAssignedEntity().get(0).getId();
actionIdsToDelete.add(deletedActionId2);
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING).content(toJson(actionIdsToDelete)).contentType(APPLICATION_JSON))
.andExpect(status().isOk());
mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
.content(toJson(actionIdsToDelete)).contentType(APPLICATION_JSON))
.andExpect(status().isNoContent());
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + deletedActionId1))
.andDo(MockMvcResultPrinter.print())
@@ -554,8 +555,9 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final Action deletedAction3 = assignmentResults.get(1).getAssignedEntity().get(0);
final String rsql = "target.name==" + deletedAction3.getTarget().getName();
mvc.perform(delete(ACTION_V1_REQUEST_MAPPING).param(REQUEST_PARAMETER_SEARCH, rsql).contentType(APPLICATION_JSON))
.andExpect(status().isOk());
mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)
.param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, rsql).contentType(APPLICATION_JSON))
.andExpect(status().isNoContent());
mvc.perform(get(ACTION_V1_REQUEST_MAPPING + "/" + deletedAction3.getId()))
.andDo(MockMvcResultPrinter.print())

View File

@@ -140,7 +140,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")
.contentType(APPLICATION_JSON).content(smList.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// create targets and assign DisSet to target
final String[] knownTargetIds = new String[] { "1", "2" };
@@ -184,7 +184,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")
.contentType(APPLICATION_JSON).content(smList.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// create Targets
final String[] knownTargetIds = new String[] { "1", "2" };
@@ -232,7 +232,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")
.contentType(APPLICATION_JSON).content(toJson(smIDs.stream().map(MgmtId::new).toList())))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// Test if size is 3
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM"))
.andDo(MockMvcResultPrinter.print())
@@ -251,7 +251,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
mvc.perform(post(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")
.contentType(APPLICATION_JSON).content(jsonIDs))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// test if size corresponds with quota
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM?limit={limit}", maxSoftwareModules * 2))
.andDo(MockMvcResultPrinter.print())
@@ -299,7 +299,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
for (final SoftwareModule softwareModule : set.getModules()) {
final Long smId = softwareModule.getId();
mvc.perform(delete(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM/" + smId))
.andExpect(status().isOk());
.andExpect(status().isNoContent());
mvc.perform(get(DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
@@ -976,7 +976,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// perform request
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// check repository content
assertThat(distributionSetManagement.findAll(PAGE)).isEmpty();
@@ -1014,7 +1014,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
mvc.perform(delete("/rest/v1/distributionsets/{dsId}", set.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
mvc.perform(get("/rest/v1/distributionsets/{dsId}", set.getId()))
.andDo(MockMvcResultPrinter.print())
@@ -1214,7 +1214,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.contentType(APPLICATION_JSON)
.content(jsonObject.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(distributionSetManagement.getMetadata(testDS.getId()).get(knownKey)).isEqualTo(updateValue);
}
@@ -1233,7 +1233,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
mvc.perform(delete("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// already deleted
mvc.perform(delete("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey))
@@ -1693,7 +1693,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
mvc.perform(post("/rest/v1/distributionsets/{ds}/invalidate", distributionSet.getId())
.contentType(APPLICATION_JSON)
.content(jsonObject.toString()))
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(targetFilterQueryManagement.find(targetFilterQuery.getId()).get().getAutoAssignDistributionSet())
.isNull();
@@ -1728,7 +1728,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
mvc.perform(post("/rest/v1/distributionsets/{ds}/invalidate", distributionSet.getId())
.content(jsonObject.toString()).contentType(APPLICATION_JSON))
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(targetFilterQueryManagement.find(targetFilterQuery.getId()).get().getAutoAssignDistributionSet()).isNull();
final Long rolloutId = rollout.getId();
@@ -1761,7 +1761,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
mvc.perform(post("/rest/v1/distributionsets/{ds}/invalidate", distributionSet.getId())
.content(jsonObject.toString()).contentType(APPLICATION_JSON))
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(rolloutManagement.get(rollout.getId()).getStatus()).isIn(RolloutStatus.RUNNING);

View File

@@ -257,7 +257,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + original.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(distributionSetTagManagement.find(original.getId())).isNotPresent();
}
@@ -350,7 +350,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" +
set.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
final List<? extends DistributionSet> updated = distributionSetManagement.findByTag(tag.getId(), PAGE).getContent();
assertThat(updated.stream().map(DistributionSet::getId).toList()).containsOnly(set.getId());
@@ -372,7 +372,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.content(toJson(sets.stream().map(DistributionSet::getId).toList()))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
final List<? extends DistributionSet> updated = distributionSetManagement.findByTag(tag.getId(), PAGE).getContent();
assertThat(updated.stream().map(DistributionSet::getId).toList())
@@ -399,7 +399,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" +
unassigned.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
final List<? extends DistributionSet> updated = distributionSetManagement.findByTag(tag.getId(), PAGE).getContent();
assertThat(updated.stream().map(DistributionSet::getId).toList())
@@ -427,7 +427,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.content(toJson(List.of(unassigned0.getId(), unassigned1.getId())))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
final List<? extends DistributionSet> updated = distributionSetManagement.findByTag(tag.getId(), PAGE).getContent();
assertThat(updated.stream().map(DistributionSet::getId).toList())

View File

@@ -179,7 +179,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
.contentType(MediaType.APPLICATION_JSON)
.content("{\"id\":" + osType.getId() + "}"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
testType = distributionSetTypeManagement.find(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
@@ -205,7 +205,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
.contentType(MediaType.APPLICATION_JSON)
.content("{\"id\":" + osType.getId() + "}"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
testType = distributionSetTypeManagement.find(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
@@ -239,7 +239,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId())
.content("{\"id\":" + moduleTypeIds.get(i) + "}").contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
}
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId())
@@ -261,7 +261,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType2.getId())
.content("{\"id\":" + moduleTypeIds.get(i) + "}").contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
}
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType2.getId())
@@ -364,7 +364,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
mvc.perform(delete("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes/{smtId}", testType.getId(),
osType.getId()).contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
testType = distributionSetTypeManagement.find(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
@@ -383,7 +383,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
mvc.perform(delete("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes/{smtId}", testType.getId(),
appType.getId()).contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
testType = distributionSetTypeManagement.find(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
@@ -440,7 +440,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
mvc.perform(delete("/rest/v1/distributionsettypes/{dsId}", testType.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES);
}
@@ -480,7 +480,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
mvc.perform(delete("/rest/v1/distributionsettypes/{dstId}", testType.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId()))
.andDo(MockMvcResultPrinter.print())

View File

@@ -168,7 +168,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
mvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/approve", rollout.getId())
.accept(MediaTypes.HAL_JSON_VALUE))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
} finally {
approvalStrategy.setApprovalNeeded(false);
}
@@ -187,7 +187,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
mvc.perform(post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deny", rollout.getId())
.accept(MediaTypes.HAL_JSON_VALUE))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
} finally {
approvalStrategy.setApprovalNeeded(false);
}
@@ -1113,7 +1113,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
// starting rollout
mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// check rollout is in starting state
mvc.perform(get("/rest/v1/rollouts/{rolloutId}", rollout.getId()).accept(MediaType.APPLICATION_JSON))
@@ -1151,7 +1151,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
// starting rollout
mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// Run here, because scheduler is disabled during tests
rolloutHandler.handleAll();
@@ -1159,7 +1159,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
// pausing rollout
mvc.perform(post("/rest/v1/rollouts/{rolloutId}/pause", rollout.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// check rollout is in running state
mvc.perform(get("/rest/v1/rollouts/{rolloutId}", rollout.getId()).accept(MediaType.APPLICATION_JSON))
@@ -1186,7 +1186,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
// starting rollout
mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// Run here, because scheduler is disabled during tests
rolloutHandler.handleAll();
@@ -1194,12 +1194,12 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
// pausing rollout
mvc.perform(post("/rest/v1/rollouts/{rolloutId}/pause", rollout.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// resume rollout
mvc.perform(post("/rest/v1/rollouts/{rolloutId}/resume", rollout.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// check rollout is in running state
mvc.perform(get("/rest/v1/rollouts/{rolloutId}", rollout.getId()).accept(MediaType.APPLICATION_JSON))
@@ -1226,7 +1226,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
// starting rollout
mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// Run here, because scheduler is disabled during tests
rolloutHandler.handleAll();
@@ -1274,7 +1274,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
// starting rollout
mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// Run here, because scheduler is disabled during tests
rolloutHandler.handleAll();
@@ -1429,7 +1429,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
// starting rollout
mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// Run here, because scheduler is disabled during tests
rolloutHandler.handleAll();
@@ -1452,7 +1452,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
mvc.perform(delete("/rest/v1/rollouts/{rolloutid}", rollout.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertStatusIs(rollout, RolloutStatus.DELETING);
}
@@ -1489,7 +1489,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
final Rollout rollout = testdataFactory.createAndStartRollout();
mvc.perform(post("/rest/v1/rollouts/{rolloutId}/stop", rollout.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
mvc.perform(get("/rest/v1/rollouts/{rolloutid}", rollout.getId()))
.andDo(MockMvcResultPrinter.print())
@@ -1716,7 +1716,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
mvc.perform(post("/rest/v1/rollouts/{rolloutId}/triggerNextGroup", rollout.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
final List<RolloutGroupStatus> groupStatus = rolloutGroupManagement.findByRollout(rollout.getId(), PAGE)
.getContent().stream().map(RolloutGroup::getStatus).toList();
@@ -1747,14 +1747,14 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
// RUNNING state
rolloutHandler.handleAll();
triggerNextGroupAndExpect(rollout, status().isOk());
triggerNextGroupAndExpect(rollout, status().isNoContent());
// PAUSED state
rolloutManagement.pauseRollout(rollout.getId());
triggerNextGroupAndExpect(rollout, status().isBadRequest());
rolloutManagement.resumeRollout(rollout.getId());
triggerNextGroupAndExpect(rollout, status().isOk());
triggerNextGroupAndExpect(rollout, status().isNoContent());
// last group already running
triggerNextGroupAndExpect(rollout, status().isBadRequest());

View File

@@ -965,7 +965,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
// delete
mvc.perform(delete("/rest/v1/softwaremodules/{smId}/artifacts/{artId}", moduleId, artifact.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// check that only one artifact is still alive and still assigned
assertThat(softwareModuleManagement.findAll(PAGE)).as("After the sm should be marked as deleted").hasSize(1);
@@ -1353,7 +1353,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", sm.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(softwareModuleManagement.findAll(PAGE)).as("After delete no softwarmodule should be available").isEmpty();
assertThatExceptionOfType(EntityNotFoundException.class) // sm doesn't exists
@@ -1388,7 +1388,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", appTypeSmId))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
mvc.perform(get("/rest/v1/softwaremodules/{smId}", appTypeSmId))
.andDo(MockMvcResultPrinter.print())
@@ -1463,7 +1463,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
mvc.perform(put("/rest/v1/softwaremodules/{swId}/metadata/{key}", sm.getId(), knownKey)
.accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON).content(jsonObject.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
final MetadataValue assertDS = softwareModuleManagement.getMetadata(sm.getId(), knownKey);
assertThat(assertDS.getValue()).as("Metadata is wrong").isEqualTo(updateValue);
@@ -1484,7 +1484,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
mvc.perform(delete("/rest/v1/softwaremodules/{swId}/metadata/{key}", smId, knownKey))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThatExceptionOfType(EntityNotFoundException.class)
.isThrownBy(() -> softwareModuleManagement.getMetadata(smId, knownKey));

View File

@@ -266,7 +266,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
mvc.perform(delete("/rest/v1/softwaremoduletypes/{smId}", testType.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(softwareModuleTypeManagement.count()).isEqualTo(3);
}
@@ -300,7 +300,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
mvc.perform(delete("/rest/v1/softwaremoduletypes/{smtId}", testType.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
mvc.perform(get("/rest/v1/softwaremoduletypes/{smtId}", testType.getId()))
.andDo(MockMvcResultPrinter.print())

View File

@@ -142,7 +142,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
final TargetFilterQuery filterQuery = createSingleTargetFilterQuery(filterName, "name==test_01");
mvc.perform(delete(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId()))
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(targetFilterQueryManagement.find(filterQuery.getId())).isNotPresent();
}

View File

@@ -91,7 +91,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
mvc.perform(put(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/newGroup/assigned")
.contentType(MediaType.APPLICATION_JSON)
.content(toJson(Arrays.asList("target1", "target2", "target3"))))
.andExpect(status().isOk());
.andExpect(status().isNoContent());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/newGroup/assigned")
@@ -122,7 +122,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
.contentType(MediaType.APPLICATION_JSON)
.content(toJson(Arrays.asList("target1", "target2", "target3")))
.param("group", "Europe/East"))
.andExpect(status().isOk());
.andExpect(status().isNoContent());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")
@@ -151,7 +151,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
mvc.perform(put(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/C")
.contentType(MediaType.APPLICATION_JSON)
.param("q", "controllerId==target*"))
.andExpect(status().isOk());
.andExpect(status().isNoContent());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")
@@ -171,7 +171,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
mvc.perform(delete(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
.contentType(MediaType.APPLICATION_JSON)
.content(toJson(Arrays.asList("target1", "target2"))))
.andExpect(status().isOk());
.andExpect(status().isNoContent());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")
@@ -196,7 +196,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
mvc.perform(delete(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING)
.contentType(MediaType.APPLICATION_JSON)
.param("q", "controllerId==target*"))
.andExpect(status().isOk());
.andExpect(status().isNoContent());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
.param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")
@@ -219,7 +219,7 @@ public class MgmtTargetGroupResourceTest extends AbstractManagementApiIntegratio
.contentType(MediaType.APPLICATION_JSON)
.param("group", "Europe/East")
.param("q", "controllerId==target*"))
.andExpect(status().isOk());
.andExpect(status().isNoContent());
mvc.perform(get(MgmtRestConstants.TARGET_GROUP_V1_REQUEST_MAPPING + "/assigned")
.param("group", "Europe/East")

View File

@@ -253,7 +253,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
testTarget.getControllerId())
.content(objectMapper.writeValueAsString(body)).contentType(APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
}
/**
@@ -267,7 +267,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM + "/" + TARGET_V1_DEACTIVATE_AUTO_CONFIRM,
testTarget.getControllerId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
}
/**
@@ -281,7 +281,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
final Status expectedStatusAfterActionConfirmationCall = Status.RUNNING;
final long actionId = doAssignmentAndTestConfirmation("targetId");
testActionConfirmation("targetId", actionId, MgmtActionConfirmationRequestBodyPut.Confirmation.CONFIRMED, expectedStatusCode,
new String[] { expectedStatusMessage1, expectedStatusMessage2 }, HttpStatus.OK, expectedStatusAfterActionConfirmationCall);
new String[] { expectedStatusMessage1, expectedStatusMessage2 }, HttpStatus.NO_CONTENT, expectedStatusAfterActionConfirmationCall);
}
/**
@@ -295,7 +295,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
final Status expectedStatusAfterActionConfirmationCall = Status.WAIT_FOR_CONFIRMATION;
final long actionId = doAssignmentAndTestConfirmation("targetId");
testActionConfirmation("targetId", actionId, MgmtActionConfirmationRequestBodyPut.Confirmation.DENIED, expectedStatusCode,
new String[] { expectedStatusMessage1, expectedStatusMessage2 }, HttpStatus.OK, expectedStatusAfterActionConfirmationCall);
new String[] { expectedStatusMessage1, expectedStatusMessage2 }, HttpStatus.NO_CONTENT, expectedStatusAfterActionConfirmationCall);
}
/**
@@ -355,7 +355,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
final List<ActionStatus> actionStatuses = new ArrayList<>(jpaAction.getActionStatus());
// confirmation call was successful, check if Action status ,status code and messages are updated appropriately
if (expectedHttpResponseStatus == HttpStatus.OK) {
if (expectedHttpResponseStatus == HttpStatus.NO_CONTENT) {
assertThat(jpaAction.getStatus()).isEqualTo(expectedGeneratedStatus);
assertThat(jpaAction.getLastActionStatusCode()).hasValue(payloadCode);
@@ -598,7 +598,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
final String knownControllerId = "knownControllerIdDelete";
testdataFactory.createTarget(knownControllerId);
mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId)).andExpect(status().isOk());
mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId)).andExpect(status().isNoContent());
assertThat(targetManagement.findByControllerId(knownControllerId)).isNotPresent();
}
@@ -2061,8 +2061,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
.accept(APPLICATION_JSON).contentType(APPLICATION_JSON)
.content(jsonObject.toString()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk())
.andExpect(content().string(""));
.andExpect(status().isNoContent());
assertThat(targetManagement.getMetadata(knownControllerId).get(KNOWN_KEY)).isEqualTo(updateValue);
}
@@ -2078,7 +2077,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
mvc.perform(delete("/rest/v1/targets/{targetId}/metadata/{key}", knownControllerId, KNOWN_KEY))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
// already deleted
mvc.perform(delete("/rest/v1/targets/{targetId}/metadata/{key}", knownControllerId, KNOWN_KEY))
@@ -2503,7 +2502,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
mvc.perform(post(TARGET_V1_REQUEST_MAPPING + "/" + targetControllerId + "/targettype")
.content("{\"id\":" + targetType.getId() + "}").contentType(APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(targetManagement.getByControllerId(targetControllerId).getTargetType().getId()).isEqualTo(targetType.getId());
}
@@ -2560,7 +2559,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
// unassign target type over rest resource
mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/" + targetControllerId + "/targettype").contentType(APPLICATION_JSON))
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(targetManagement.getByControllerId(targetControllerId).getTargetType()).isNull();
}
@@ -2748,7 +2747,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
mvc.perform(delete(TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions", testTarget.getControllerId()).param("keepLast", "5"))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
//the last 5 actions should be left
List<Action> actions = deploymentManagement.findActionsByTarget(testTarget.getControllerId(), PAGE).getContent();
@@ -2794,7 +2793,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
.content(toJson(evenActionIds))
.contentType(APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
long remaining = actionRepository.countByTargetId(testTarget.getId());
Assertions.assertEquals(10 - evenActionIds.size(), remaining);

View File

@@ -223,7 +223,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + original.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(targetTagManagement.find(original.getId())).isNotPresent();
}
@@ -316,7 +316,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" +
assigned.getControllerId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
final List<Target> updated = targetManagement.findByTag(tag.getId(), PAGE).getContent();
assertThat(updated.stream().map(Target::getControllerId).toList()).containsOnly(assigned.getControllerId());
@@ -340,7 +340,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.content(toJson(List.of(assigned0.getControllerId(), assigned1.getControllerId())))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
final List<Target> updated = targetManagement.findByTag(tag.getId(), PAGE).getContent();
assertThat(updated.stream().map(Target::getControllerId).toList())
@@ -462,7 +462,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.content(toJson(withMissing))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent().stream().map(Target::getControllerId).sorted().toList())
.isEqualTo(targets.stream().sorted().toList());
}
@@ -486,7 +486,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" +
unassigned.getControllerId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
final List<Target> updated = targetManagement.findByTag(tag.getId(), PAGE).getContent();
assertThat(updated.stream().map(Target::getControllerId).toList())
@@ -514,7 +514,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.content(toJson(Arrays.asList(unassigned0.getControllerId(), unassigned1.getControllerId())))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
final List<Target> updated = targetManagement.findByTag(tag.getId(), PAGE).getContent();
assertThat(updated.stream().map(Target::getControllerId).toList())
@@ -643,7 +643,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.content(toJson(withMissing))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent()).isEmpty();
}
}

View File

@@ -349,7 +349,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
mvc.perform(post(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId())
.content("[{\"id\":" + standardDsType.getId() + "}]").contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
testType = targetTypeManagement.find(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER);
@@ -405,7 +405,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
mvc.perform(delete(TARGETTYPE_DSTYPE_SINGLE_ENDPOINT, testType.getId(), standardDsType.getId())
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
testType = targetTypeManagement.find(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER);
@@ -425,7 +425,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/" + standardDsType.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
testType = targetTypeManagement.find(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER);
@@ -447,7 +447,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
mvc.perform(delete(TARGETTYPE_SINGLE_ENDPOINT, testType.getId()))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
assertThat(targetTypeManagement.count()).isZero();
}
@@ -646,7 +646,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
.content(toJson(dsTypeIds.subList(0, dsTypeIds.size() - 1).stream().map(MgmtId::new).toList()))
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
mvc.perform(post(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId())
.content("[{\"id\":" + dsTypeIds.get(dsTypeIds.size() - 1) + "}]")

View File

@@ -287,7 +287,7 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg
mvc.perform(delete(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}",
TenantConfigurationProperties.TenantConfigurationKey.AUTHENTICATION_GATEWAY_SECURITY_TOKEN_KEY))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
.andExpect(status().isNoContent());
}
/**