Search in sources :

Example 1 with ProductExecutionProfilesList

use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutionProfilesList in project sechub by mercedes-benz.

the class ProductExecutionProfileRestControllerRestDocTest method restDoc_admin_fetches_profiles_list.

@Test
@UseCaseRestDoc(useCase = UseCaseAdminFetchesExecutionProfileList.class)
public void restDoc_admin_fetches_profiles_list() throws Exception {
    /* prepare */
    String apiEndpoint = https(PORT_USED).buildAdminFetchesListOfProductExecutionProfiles();
    Class<? extends Annotation> useCase = UseCaseAdminFetchesExecutionProfileList.class;
    TestExecutionProfileList profileList = new TestExecutionProfileList();
    TestExecutionProfileListEntry entry1 = new TestExecutionProfileListEntry();
    entry1.description = "A short decription for profile1";
    entry1.id = "profile1";
    TestExecutionProfileListEntry entry2 = new TestExecutionProfileListEntry();
    entry2.description = "A short decription for profile2";
    entry2.id = "profile2";
    profileList.executionProfiles.add(entry1);
    profileList.executionProfiles.add(entry2);
    ProductExecutionProfilesList list = JSONConverter.get().fromJSON(ProductExecutionProfilesList.class, JSONConverter.get().toJSON(profileList));
    when(fetchListService.fetchProductExecutionProfileList()).thenReturn(list);
    /* execute + test @formatter:off */
    this.mockMvc.perform(get(apiEndpoint).contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).responseSchema(OpenApiSchema.EXECUTION_PROFILE_LIST.getSchema()).and().document(responseFields(fieldWithPath("type").description("Always `executorProfileList` as an identifier for the list"), fieldWithPath("executionProfiles[]." + PROPERTY_ID).description("The profile id"), fieldWithPath("executionProfiles[]." + PROPERTY_DESCRIPTION).description("A profile description"), fieldWithPath("executionProfiles[]." + PROPERTY_ENABLED).description("Enabled state of profile"))));
/* @formatter:on */
}
Also used : TestExecutionProfileListEntry(com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileListEntry) UseCaseAdminFetchesExecutionProfileList(com.mercedesbenz.sechub.sharedkernel.usecases.admin.config.UseCaseAdminFetchesExecutionProfileList) TestExecutionProfileList(com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileList) ProductExecutionProfilesList(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutionProfilesList) UseCaseRestDoc(com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest) Test(org.junit.Test)

Aggregations

ProductExecutionProfilesList (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutionProfilesList)1 UseCaseRestDoc (com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc)1 UseCaseAdminFetchesExecutionProfileList (com.mercedesbenz.sechub.sharedkernel.usecases.admin.config.UseCaseAdminFetchesExecutionProfileList)1 TestExecutionProfileList (com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileList)1 TestExecutionProfileListEntry (com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileListEntry)1 Test (org.junit.Test)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1