Cleanup TargetManagement (#2601)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -142,14 +142,9 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
@Override
|
||||
@AuditLog(entity = "Target", type = AuditLog.Type.UPDATE, description = "Update Target")
|
||||
public ResponseEntity<MgmtTarget> updateTarget(final String targetId, final MgmtTargetRequestBody targetRest) {
|
||||
if (targetRest.getRequestAttributes() != null) {
|
||||
if (Boolean.TRUE.equals(targetRest.getRequestAttributes())) {
|
||||
targetManagement.requestControllerAttributes(targetId);
|
||||
} else {
|
||||
return ResponseEntity.badRequest().build();
|
||||
}
|
||||
if (targetRest.getRequestAttributes() != null && !Boolean.TRUE.equals(targetRest.getRequestAttributes())) {
|
||||
return ResponseEntity.badRequest().build();
|
||||
}
|
||||
|
||||
final Target targetToUpdate = targetManagement.getByControllerId(targetId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, targetId));
|
||||
final TargetType targetType = Optional.ofNullable(targetRest.getTargetType())
|
||||
@@ -180,7 +175,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
@Override
|
||||
@AuditLog(entity = "Target", type = AuditLog.Type.DELETE, description = "Delete Target")
|
||||
public ResponseEntity<Void> deleteTarget(final String targetId) {
|
||||
this.targetManagement.deleteByControllerID(targetId);
|
||||
this.targetManagement.deleteByControllerId(targetId);
|
||||
log.debug("{} target deleted, return status {}", targetId, HttpStatus.OK);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@@ -1440,7 +1440,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
|
||||
assertThat(
|
||||
actionRepository
|
||||
.findAll(ActionSpecifications.byDistributionSetId(createdDs.getId()), PAGE)
|
||||
.findAll(byDistributionSetId(createdDs.getId()), PAGE)
|
||||
.map(Action.class::cast).getContent()).hasSize(1)
|
||||
.allMatch(action -> {
|
||||
if (!confirmationFlowActive) {
|
||||
|
||||
@@ -1687,7 +1687,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
|
||||
assertThat(
|
||||
actionRepository
|
||||
.findAll(ActionSpecifications.byDistributionSetId(set.getId()), PAGE)
|
||||
.findAll(byDistributionSetId(set.getId()), PAGE)
|
||||
.map(Action.class::cast).getContent()).hasSize(1)
|
||||
.allMatch(action -> {
|
||||
if (!confirmationFlowActive) {
|
||||
@@ -2038,12 +2038,10 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
knownControllerAttrs.put("b.2", "2");
|
||||
testdataFactory.createTarget(knownTargetId);
|
||||
controllerManagement.updateControllerAttributes(knownTargetId, knownControllerAttrs, null);
|
||||
assertThat(targetManagement.isControllerAttributesRequested(knownTargetId)).isFalse();
|
||||
assertThat(targetManagement.getByControllerId(knownTargetId).orElseThrow().isRequestControllerAttributes()).isFalse();
|
||||
|
||||
verifyAttributeUpdateCanBeRequested(knownTargetId);
|
||||
|
||||
verifyRequestAttributesAttributeIsOptional(knownTargetId);
|
||||
|
||||
verifyResettingRequestAttributesIsNotAllowed(knownTargetId);
|
||||
}
|
||||
|
||||
@@ -2988,7 +2986,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk());
|
||||
|
||||
assertThat(targetManagement.isControllerAttributesRequested(knownTargetId)).isTrue();
|
||||
assertThat(targetManagement.getByControllerId(knownTargetId).orElseThrow().isRequestControllerAttributes()).isTrue();
|
||||
}
|
||||
|
||||
private void verifyRequestAttributesAttributeIsOptional(final String knownTargetId) throws Exception {
|
||||
@@ -3008,7 +3006,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
assertThat(targetManagement.isControllerAttributesRequested(knownTargetId)).isTrue();
|
||||
assertThat(targetManagement.getByControllerId(knownTargetId).orElseThrow().isRequestControllerAttributes()).isTrue();
|
||||
}
|
||||
|
||||
private String getCreateTargetsListJsonString(final String controllerId, final String name, final String description) {
|
||||
|
||||
Reference in New Issue
Block a user