diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java index 2c655b6fc..1d210172d 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java @@ -1399,8 +1399,9 @@ public class TestdataFactory { */ public TargetType findOrCreateTargetType(final String targetTypeName) { return targetTypeManagement.getByName(targetTypeName) - .orElseGet(() -> targetTypeManagement.create(entityFactory.targetType().create().name(targetTypeName) - .description(targetTypeName + " description").colour(DEFAULT_COLOUR))); + .orElseGet(() -> targetTypeManagement.create(entityFactory.targetType().create() + .name(targetTypeName).description(targetTypeName + " description") + .key(targetTypeName + " key").colour(DEFAULT_COLOUR))); } /** @@ -1431,8 +1432,9 @@ public class TestdataFactory { public List createTargetTypes(final String targetTypePrefix, final int count) { final List result = Lists.newArrayListWithExpectedSize(count); for (int i = 0; i < count; i++) { - result.add(entityFactory.targetType().create().name(targetTypePrefix + i) - .description(targetTypePrefix + " description").colour(DEFAULT_COLOUR)); + result.add(entityFactory.targetType().create() + .name(targetTypePrefix + i).description(targetTypePrefix + " description") + .key(targetTypePrefix + i + " key").colour(DEFAULT_COLOUR)); } return targetTypeManagement.create(result); } diff --git a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtTypeEntity.java b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtTypeEntity.java new file mode 100644 index 000000000..3e87f4026 --- /dev/null +++ b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtTypeEntity.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2023 Bosch.IO GmbH and others + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.hawkbit.mgmt.json.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * A json annotated rest model for Type to RESTful API representation. + * + */ +public abstract class MgmtTypeEntity extends MgmtNamedEntity { + + @JsonProperty(required = true) + @Schema(example = "id.t23") + private String key; + + @JsonProperty + @Schema(example = "brown") + private String colour; + + @JsonProperty + @Schema(example = "false") + private boolean deleted; + + public String getKey() { + return key; + } + + public void setKey(final String key) { + this.key = key; + } + + public String getColour() { + return colour; + } + + public void setColour(String colour) { + this.colour = colour; + } + + public boolean isDeleted() { + return deleted; + } + + public void setDeleted(final boolean deleted) { + this.deleted = deleted; + } +} diff --git a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetType.java b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetType.java index bebd7e4c1..00af27af3 100644 --- a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetType.java +++ b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetType.java @@ -10,49 +10,25 @@ package org.eclipse.hawkbit.mgmt.json.model.distributionsettype; import io.swagger.v3.oas.annotations.media.Schema; -import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; +import org.eclipse.hawkbit.mgmt.json.model.MgmtTypeEntity; /** * A json annotated rest model for SoftwareModuleType to RESTful API * representation. - * - * - * - * */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MgmtDistributionSetType extends MgmtNamedEntity { +public class MgmtDistributionSetType extends MgmtTypeEntity { @JsonProperty(value = "id", required = true) @Schema(example = "99") private Long moduleId; - @JsonProperty(required = true) - @Schema(example = "os_app") - private String key; - - @JsonProperty - @Schema(example = "false") - private boolean deleted; - - @JsonProperty - @Schema(example = "black") - private String colour; - - public boolean isDeleted() { - return deleted; - } - - public void setDeleted(final boolean deleted) { - this.deleted = deleted; - } - /** * @return the moduleId */ @@ -67,35 +43,4 @@ public class MgmtDistributionSetType extends MgmtNamedEntity { public void setModuleId(final Long moduleId) { this.moduleId = moduleId; } - - /** - * @return the key - */ - public String getKey() { - return key; - } - - /** - * @param key - * the key to set - */ - public void setKey(final String key) { - this.key = key; - } - - /** - * @return the colour - */ - public String getColour() { - return colour; - } - - /** - * @param colour - * the colour to set - */ - public void setColour(String colour) { - this.colour = colour; - } - } diff --git a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleType.java b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleType.java index 68af185f4..e5d888bda 100644 --- a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleType.java +++ b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleType.java @@ -10,50 +10,29 @@ package org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype; import io.swagger.v3.oas.annotations.media.Schema; -import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; +import org.eclipse.hawkbit.mgmt.json.model.MgmtTypeEntity; /** * A json annotated rest model for SoftwareModuleType to RESTful API * representation. - * */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MgmtSoftwareModuleType extends MgmtNamedEntity { +public class MgmtSoftwareModuleType extends MgmtTypeEntity { @JsonProperty(value = "id", required = true) @Schema(example = "83") private Long moduleId; - @JsonProperty(required = true) - @Schema(example = "OS") - private String key; - @JsonProperty @Schema(example = "1") private int maxAssignments; - @JsonProperty - @Schema(example = "false") - private boolean deleted; - - @JsonProperty - @Schema(example = "brown") - private String colour; - - public boolean isDeleted() { - return deleted; - } - - public void setDeleted(final boolean deleted) { - this.deleted = deleted; - } - public Long getModuleId() { return moduleId; } @@ -62,14 +41,6 @@ public class MgmtSoftwareModuleType extends MgmtNamedEntity { this.moduleId = moduleId; } - public String getKey() { - return key; - } - - public void setKey(final String key) { - this.key = key; - } - public int getMaxAssignments() { return maxAssignments; } @@ -77,12 +48,4 @@ public class MgmtSoftwareModuleType extends MgmtNamedEntity { public void setMaxAssignments(final int maxAssignments) { this.maxAssignments = maxAssignments; } - - public String getColour() { - return colour; - } - - public void setColour(String colour) { - this.colour = colour; - } } diff --git a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targettype/MgmtTargetType.java b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targettype/MgmtTargetType.java index 005396598..6645868df 100644 --- a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targettype/MgmtTargetType.java +++ b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targettype/MgmtTargetType.java @@ -13,25 +13,20 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.v3.oas.annotations.media.Schema; -import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; +import org.eclipse.hawkbit.mgmt.json.model.MgmtTypeEntity; /** * A json annotated rest model for TargetType to RESTful API * representation. - * */ @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MgmtTargetType extends MgmtNamedEntity { +public class MgmtTargetType extends MgmtTypeEntity { @JsonProperty(value = "id", required = true) @Schema(example = "26") private Long typeId; - @JsonProperty - @Schema(example = "rgb(255,255,255") - private String colour; - /** * @return target type ID */ @@ -46,20 +41,4 @@ public class MgmtTargetType extends MgmtNamedEntity { public void setTypeId(final Long typeId) { this.typeId = typeId; } - - /** - * - * @return the colour - */ - public String getColour() { - return colour; - } - - /** - * @param colour - * the colour to set - */ - public void setColour(String colour) { - this.colour = colour; - } } diff --git a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targettype/MgmtTargetTypeRequestBodyPost.java b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targettype/MgmtTargetTypeRequestBodyPost.java index 230b5dec4..b05ffce91 100644 --- a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targettype/MgmtTargetTypeRequestBodyPost.java +++ b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targettype/MgmtTargetTypeRequestBodyPost.java @@ -12,6 +12,7 @@ package org.eclipse.hawkbit.mgmt.json.model.targettype; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeAssignment; import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost; import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssigment; @@ -20,7 +21,11 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModule * Request Body for TargetType POST. * */ -public class MgmtTargetTypeRequestBodyPost extends MgmtTargetTypeRequestBodyPut{ +public class MgmtTargetTypeRequestBodyPost extends MgmtTargetTypeRequestBodyPut { + + @JsonProperty + @Schema(example = "id.t23") + private String key; @JsonProperty private List compatibledistributionsettypes; @@ -42,6 +47,15 @@ public class MgmtTargetTypeRequestBodyPost extends MgmtTargetTypeRequestBodyPut{ return this; } + public MgmtTargetTypeRequestBodyPost setKey(final String key) { + this.key = key; + return this; + } + + public String getKey() { + return key; + } + @Override public MgmtTargetTypeRequestBodyPost setColour(final String colour) { super.setColour(colour); diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java index d8ed5ff04..da54788ba 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java @@ -80,11 +80,8 @@ final class MgmtDistributionSetTypeMapper { static MgmtDistributionSetType toResponse(final DistributionSetType type) { final MgmtDistributionSetType result = new MgmtDistributionSetType(); - MgmtRestModelMapper.mapNamedToNamed(result, type); - result.setKey(type.getKey()); + MgmtRestModelMapper.mapTypeToType(result, type); result.setModuleId(type.getId()); - result.setDeleted(type.isDeleted()); - result.setColour(type.getColour()); result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(result.getModuleId())) .withSelfRel().expand()); diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java index 1fc282831..6bc2980f5 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java @@ -11,12 +11,14 @@ package org.eclipse.hawkbit.mgmt.rest.resource; import org.eclipse.hawkbit.mgmt.json.model.MgmtBaseEntity; import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; +import org.eclipse.hawkbit.mgmt.json.model.MgmtTypeEntity; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtCancelationType; import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.DistributionSetInvalidation.CancelationType; import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity; +import org.eclipse.hawkbit.repository.model.Type; /** * A mapper which maps repository model to RESTful model representation and @@ -48,6 +50,14 @@ public final class MgmtRestModelMapper { response.setDescription(base.getDescription()); } + static void mapTypeToType(final MgmtTypeEntity response, final Type base) { + mapNamedToNamed(response, base); + + response.setKey(base.getKey()); + response.setColour(base.getColour()); + response.setDeleted(base.isDeleted()); + } + /** * Convert the given {@link MgmtActionType} into a corresponding repository * {@link ActionType}. diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java index 3e8ef51a2..f5999c02b 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java @@ -65,12 +65,9 @@ final class MgmtSoftwareModuleTypeMapper { static MgmtSoftwareModuleType toResponse(final SoftwareModuleType type) { final MgmtSoftwareModuleType result = new MgmtSoftwareModuleType(); - MgmtRestModelMapper.mapNamedToNamed(result, type); - result.setKey(type.getKey()); + MgmtRestModelMapper.mapTypeToType(result, type); result.setMaxAssignments(type.getMaxAssignments()); result.setModuleId(type.getId()); - result.setDeleted(type.isDeleted()); - result.setColour(type.getColour()); result.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(result.getModuleId())) .withSelfRel().expand()); diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeMapper.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeMapper.java index 236377a0f..ca8ac807e 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeMapper.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeMapper.java @@ -29,9 +29,7 @@ import org.eclipse.hawkbit.repository.model.TargetType; import org.eclipse.hawkbit.rest.data.ResponseList; /** - * A mapper which maps repository model to RESTful model representation and - * back. - * + * A mapper which maps repository model to RESTful model representation and back. */ public final class MgmtTargetTypeMapper { @@ -50,8 +48,9 @@ public final class MgmtTargetTypeMapper { private static TargetTypeCreate fromRequest(final EntityFactory entityFactory, final MgmtTargetTypeRequestBodyPost targetTypesRest) { - return entityFactory.targetType().create().name(targetTypesRest.getName()) - .description(targetTypesRest.getDescription()).colour(targetTypesRest.getColour()) + return entityFactory.targetType().create() + .name(targetTypesRest.getName()).description(targetTypesRest.getDescription()) + .key(targetTypesRest.getKey()).colour(targetTypesRest.getColour()) .compatible(getDistributionSets(targetTypesRest)); } @@ -70,9 +69,9 @@ public final class MgmtTargetTypeMapper { static MgmtTargetType toResponse(final TargetType type) { final MgmtTargetType result = new MgmtTargetType(); - MgmtRestModelMapper.mapNamedToNamed(result, type); + + MgmtRestModelMapper.mapTypeToType(result, type); result.setTypeId(type.getId()); - result.setColour(type.getColour()); result.add( linkTo(methodOn(MgmtTargetTypeRestApi.class).getTargetType(result.getTypeId())).withSelfRel().expand()); return result; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java index b6740b30d..ec03dddf0 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java @@ -98,8 +98,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("$.lastModifiedBy", equalTo(TEST_USER))) .andExpect(jsonPath("$.lastModifiedAt", equalTo(testType.getLastModifiedAt()))) .andExpect(jsonPath("$._links.self.href", equalTo("http://localhost/rest/v1/targettypes/" + typeId))) - .andExpect(jsonPath("$.deleted").doesNotExist()) - .andExpect(jsonPath("$.key").doesNotExist()) + .andExpect(jsonPath("$.deleted", equalTo(false))) + .andExpect(jsonPath("$.key", equalTo(typeName + " key"))) .andExpect(jsonPath("$._links.compatibledistributionsettypes.href", equalTo("http://localhost/rest/v1/targettypes/" + typeId + "/compatibledistributionsettypes"))); } @@ -129,8 +129,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].lastModifiedBy", contains(TEST_USER))) .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].lastModifiedAt", contains(testTypes.get(index).getLastModifiedAt()))) - .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].deleted").doesNotExist()) - .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].key").doesNotExist()) + .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].deleted", contains(false))) + .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].key", contains(typeName + index + " key"))) .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')]._links.self.href", contains("http://localhost/rest/v1/targettypes/" + typeId))) .andExpect( @@ -179,8 +179,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("$.content.[0].createdAt", equalTo(testTypeC.getCreatedAt()))) .andExpect(jsonPath("$.content.[0].lastModifiedBy", equalTo(TEST_USER))) .andExpect(jsonPath("$.content.[0].lastModifiedAt", equalTo(testTypeC.getLastModifiedAt()))) - .andExpect(jsonPath("$.content.[0].deleted").doesNotExist()) - .andExpect(jsonPath("$.content.[0].key").doesNotExist()) + .andExpect(jsonPath("$.content.[0].deleted", equalTo(false))) + .andExpect(jsonPath("$.content.[0].key", equalTo(typeNameC + " key"))) .andExpect(jsonPath("$.content.[0]._links.self.href", equalTo("http://localhost/rest/v1/targettypes/" + testTypeC.getId()))) .andExpect(jsonPath("$.content.[0]._links.compatibledistributionsettypes.href").doesNotExist()) @@ -200,8 +200,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("$.content.[0].createdAt", equalTo(testTypeA.getCreatedAt()))) .andExpect(jsonPath("$.content.[0].lastModifiedBy", equalTo(TEST_USER))) .andExpect(jsonPath("$.content.[0].lastModifiedAt", equalTo(testTypeA.getLastModifiedAt()))) - .andExpect(jsonPath("$.content.[0].deleted").doesNotExist()) - .andExpect(jsonPath("$.content.[0].key").doesNotExist()) + .andExpect(jsonPath("$.content.[0].deleted", equalTo(false))) + .andExpect(jsonPath("$.content.[0].key", equalTo(typeNameA + " key"))) .andExpect(jsonPath("$.content.[0]._links.self.href", equalTo("http://localhost/rest/v1/targettypes/" + testTypeA.getId()))) .andExpect(jsonPath("$.content.[0]._links.compatibledistributionsettypes.href").doesNotExist()) @@ -268,8 +268,9 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { @WithUser(principal = TEST_USER, allSpPermissions = true) @Description("Checks the correct behaviour of /rest/v1/targettypes/{id} GET requests.") void getUpdatedTargetType() throws Exception { - TargetType testType = createTestTargetTypeInDB("TestTypeGET"); - String typeNameUpdated = "TestTypeGETupdated"; + final String initialTypeName = "TestTypeGET"; + TargetType testType = createTestTargetTypeInDB(initialTypeName); + final String typeNameUpdated = "TestTypeGETupdated"; testType = targetTypeManagement.update(entityFactory.targetType().update(testType.getId()).name(typeNameUpdated) .description("Updated Description").colour("#ffffff")); @@ -283,8 +284,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("$.createdAt", equalTo(testType.getCreatedAt()))) .andExpect(jsonPath("$.lastModifiedBy", equalTo(TEST_USER))) .andExpect(jsonPath("$.lastModifiedAt", equalTo(testType.getLastModifiedAt()))) - .andExpect(jsonPath("$.deleted").doesNotExist()) - .andExpect(jsonPath("$.key").doesNotExist()); + .andExpect(jsonPath("$.deleted", equalTo(false))) + .andExpect(jsonPath("$.key", equalTo(initialTypeName + " key"))); } @Test @@ -437,7 +438,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { put(TARGETTYPE_SINGLE_ENDPOINT, testType.getId()).content(body).contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("$.id", equalTo(testType.getId().intValue()))) - .andExpect(jsonPath("$.deleted").doesNotExist()); + .andExpect(jsonPath("$.deleted", equalTo(false))); // don't delete with update } @Test @@ -623,8 +624,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("$[" + index + "].createdAt").exists()) .andExpect(jsonPath("$[" + index + "].lastModifiedBy", equalTo(TEST_USER))) .andExpect(jsonPath("$[" + index + "].lastModifiedAt").exists()) - .andExpect(jsonPath("$[" + index + "].key").doesNotExist()) - .andExpect(jsonPath("$[" + index + "].deleted").doesNotExist()) + .andExpect(jsonPath("$[" + index + "].deleted", equalTo(false))) + .andExpect(jsonPath("$[" + index + "].key", startsWith("TestTypePOST"))) .andExpect(jsonPath("$[" + index + "]._links.self.href", startsWith("http://localhost/rest/v1/targettypes/"))) .andExpect(