Fix output folder for REST docu tests (#1109)
* Fix output folder for REST docu tests Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io> * Add description to abstract method Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>
This commit is contained in:
@@ -55,10 +55,14 @@ import io.qameta.allure.Story;
|
|||||||
public class RootControllerDocumentationTest extends AbstractApiRestDocumentation {
|
public class RootControllerDocumentationTest extends AbstractApiRestDocumentation {
|
||||||
private static final String CONTROLLER_ID = "CONTROLLER_ID";
|
private static final String CONTROLLER_ID = "CONTROLLER_ID";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getResourceName() {
|
||||||
|
return "rootcontroller";
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
host = "ddi-api.host";
|
host = "ddi-api.host";
|
||||||
resourceName = "rootcontroller";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ import io.qameta.allure.Feature;
|
|||||||
* Parent class for all Management API rest documentation classes.
|
* Parent class for all Management API rest documentation classes.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Feature("Documentation Verfication - API")
|
@Feature("Documentation Verification - API")
|
||||||
@ExtendWith(RestDocumentationExtension.class)
|
@ExtendWith(RestDocumentationExtension.class)
|
||||||
@ContextConfiguration(classes = { DdiApiConfiguration.class, MgmtApiConfiguration.class, RestConfiguration.class,
|
@ContextConfiguration(classes = { DdiApiConfiguration.class, MgmtApiConfiguration.class, RestConfiguration.class,
|
||||||
RepositoryApplicationConfiguration.class, TestConfiguration.class, TestSupportBinderAutoConfiguration.class })
|
RepositoryApplicationConfiguration.class, TestConfiguration.class, TestSupportBinderAutoConfiguration.class })
|
||||||
@@ -80,17 +80,23 @@ public abstract class AbstractApiRestDocumentation extends AbstractRestIntegrati
|
|||||||
|
|
||||||
protected MockMvc mockMvc;
|
protected MockMvc mockMvc;
|
||||||
|
|
||||||
protected String resourceName = "output";
|
|
||||||
|
|
||||||
protected RestDocumentationResultHandler document;
|
protected RestDocumentationResultHandler document;
|
||||||
|
|
||||||
protected String arrayPrefix;
|
protected String arrayPrefix;
|
||||||
|
|
||||||
protected String host = "management-api.host";
|
protected String host = "management-api.host";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The generated REST docs snippets will be outputted to an own resource folder.
|
||||||
|
* The child class has to specify the name of that output folder where to put its corresponding snippets.
|
||||||
|
*
|
||||||
|
* @return the name of the resource folder
|
||||||
|
*/
|
||||||
|
public abstract String getResourceName();
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
protected void setupMvc(RestDocumentationContextProvider restDocContext) {
|
protected void setupMvc(final RestDocumentationContextProvider restDocContext) {
|
||||||
this.document = document(resourceName + "/{method-name}", preprocessRequest(prettyPrint()),
|
this.document = document(getResourceName() + "/{method-name}", preprocessRequest(prettyPrint()),
|
||||||
preprocessResponse(prettyPrint()));
|
preprocessResponse(prettyPrint()));
|
||||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
|
this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
|
||||||
.apply(MockMvcRestDocumentation.documentationConfiguration(restDocContext).uris()
|
.apply(MockMvcRestDocumentation.documentationConfiguration(restDocContext).uris()
|
||||||
|
|||||||
@@ -56,9 +56,13 @@ public class DistributionSetTagResourceDocumentationTest extends AbstractApiRest
|
|||||||
|
|
||||||
private DistributionSet distributionSet;
|
private DistributionSet distributionSet;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getResourceName() {
|
||||||
|
return "distributionsettag";
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
resourceName = "distributionsettag";
|
|
||||||
distributionSet = createDistributionSet();
|
distributionSet = createDistributionSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
|
|||||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.restdocs.payload.JsonFieldType;
|
import org.springframework.restdocs.payload.JsonFieldType;
|
||||||
@@ -54,9 +53,9 @@ import io.qameta.allure.Story;
|
|||||||
@Story("DistributionSetTypes Resource")
|
@Story("DistributionSetTypes Resource")
|
||||||
public class DistributionSetTypesDocumentationTest extends AbstractApiRestDocumentation {
|
public class DistributionSetTypesDocumentationTest extends AbstractApiRestDocumentation {
|
||||||
|
|
||||||
@BeforeEach
|
@Override
|
||||||
public void setUp() {
|
public String getResourceName() {
|
||||||
this.resourceName = "distributionsettypes";
|
return "distributionsettypes";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
|||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.hateoas.MediaTypes;
|
import org.springframework.hateoas.MediaTypes;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@@ -58,9 +57,9 @@ import io.qameta.allure.Story;
|
|||||||
@Story("DistributionSet Resource")
|
@Story("DistributionSet Resource")
|
||||||
public class DistributionSetsDocumentationTest extends AbstractApiRestDocumentation {
|
public class DistributionSetsDocumentationTest extends AbstractApiRestDocumentation {
|
||||||
|
|
||||||
@BeforeEach
|
@Override
|
||||||
public void setUp() {
|
public String getResourceName() {
|
||||||
resourceName = "distributionsets";
|
return "distributionsets";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -452,7 +451,6 @@ public class DistributionSetsDocumentationTest extends AbstractApiRestDocumentat
|
|||||||
.andDo(this.document.document(pathParameters(
|
.andDo(this.document.document(pathParameters(
|
||||||
parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID),
|
parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID),
|
||||||
parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID))));
|
parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID))));
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -591,7 +589,7 @@ public class DistributionSetsDocumentationTest extends AbstractApiRestDocumentat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Update a single meta data value for speficic key." + " Required Permission: "
|
@Description("Update a single meta data value for specific key." + " Required Permission: "
|
||||||
+ SpPermission.UPDATE_REPOSITORY)
|
+ SpPermission.UPDATE_REPOSITORY)
|
||||||
public void updateMetadata() throws Exception {
|
public void updateMetadata() throws Exception {
|
||||||
// prepare and create metadata for update
|
// prepare and create metadata for update
|
||||||
|
|||||||
@@ -68,9 +68,13 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RolloutTestApprovalStrategy approvalStrategy;
|
private RolloutTestApprovalStrategy approvalStrategy;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getResourceName() {
|
||||||
|
return "rollouts";
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
this.resourceName = "rollouts";
|
|
||||||
arrayPrefix = "content[].";
|
arrayPrefix = "content[].";
|
||||||
approvalStrategy.setApprovalNeeded(false);
|
approvalStrategy.setApprovalNeeded(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
|
|||||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.restdocs.payload.JsonFieldType;
|
import org.springframework.restdocs.payload.JsonFieldType;
|
||||||
@@ -47,9 +46,9 @@ import io.qameta.allure.Story;
|
|||||||
@Story("Softwaremoduletypes Resource")
|
@Story("Softwaremoduletypes Resource")
|
||||||
public class SoftwaremoduleTypesDocumentationTest extends AbstractApiRestDocumentation {
|
public class SoftwaremoduleTypesDocumentationTest extends AbstractApiRestDocumentation {
|
||||||
|
|
||||||
@BeforeEach
|
@Override
|
||||||
public void setUp() {
|
public String getResourceName() {
|
||||||
this.resourceName = "softwaremoduletypes";
|
return "softwaremoduletypes";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
|||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.hateoas.MediaTypes;
|
import org.springframework.hateoas.MediaTypes;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@@ -58,9 +57,9 @@ import io.qameta.allure.Story;
|
|||||||
@Story("Softwaremodule Resource")
|
@Story("Softwaremodule Resource")
|
||||||
public class SoftwaremodulesDocumentationTest extends AbstractApiRestDocumentation {
|
public class SoftwaremodulesDocumentationTest extends AbstractApiRestDocumentation {
|
||||||
|
|
||||||
@BeforeEach
|
@Override
|
||||||
public void setUp() {
|
public String getResourceName() {
|
||||||
resourceName = "softwaremodules";
|
return "softwaremodules";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric;
|
|||||||
import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
|
import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
|
||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.restdocs.payload.JsonFieldType;
|
import org.springframework.restdocs.payload.JsonFieldType;
|
||||||
@@ -54,9 +53,9 @@ public class TargetFilterQueriesResourceDocumentationTest extends AbstractApiRes
|
|||||||
private static final String EXAMPLE_TFQ_NAME = "filter1";
|
private static final String EXAMPLE_TFQ_NAME = "filter1";
|
||||||
private static final String EXAMPLE_TFQ_QUERY = "name==*";
|
private static final String EXAMPLE_TFQ_QUERY = "name==*";
|
||||||
|
|
||||||
@BeforeEach
|
@Override
|
||||||
public void setUp() {
|
public String getResourceName() {
|
||||||
resourceName = "targetfilters";
|
return "targetfilters";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
|
|||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Sort.Direction;
|
import org.springframework.data.domain.Sort.Direction;
|
||||||
@@ -68,9 +67,9 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
|
|||||||
|
|
||||||
private final String targetId = "137";
|
private final String targetId = "137";
|
||||||
|
|
||||||
@BeforeEach
|
@Override
|
||||||
public void setUp() {
|
public String getResourceName() {
|
||||||
resourceName = "targets";
|
return "targets";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -57,9 +57,13 @@ public class TargetTagResourceDocumentationTest extends AbstractApiRestDocumenta
|
|||||||
|
|
||||||
private DistributionSet distributionSet;
|
private DistributionSet distributionSet;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getResourceName() {
|
||||||
|
return "targettag";
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
resourceName = "targettag";
|
|
||||||
distributionSet = createDistributionSet();
|
distributionSet = createDistributionSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
|
|||||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
|
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
|
||||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@@ -95,9 +94,9 @@ public class TenantResourceDocumentationTest extends AbstractApiRestDocumentatio
|
|||||||
@Autowired
|
@Autowired
|
||||||
protected TenantConfigurationProperties tenantConfigurationProperties;
|
protected TenantConfigurationProperties tenantConfigurationProperties;
|
||||||
|
|
||||||
@BeforeEach
|
@Override
|
||||||
public void setUp() {
|
public String getResourceName() {
|
||||||
resourceName = "tenant";
|
return "tenant";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user