diff options
23 files changed, 342 insertions, 16 deletions
diff --git a/workflow-designer-be/pom.xml b/workflow-designer-be/pom.xml index 7b2197e0..a1416588 100644 --- a/workflow-designer-be/pom.xml +++ b/workflow-designer-be/pom.xml @@ -80,7 +80,11 @@ <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-logging-api</artifactId> <version>${onap.version}</version> - <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-logging-spring</artifactId> + <version>${onap.version}</version> </dependency> <dependency> <groupId>org.openecomp.sdc</groupId> diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionResponse.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionResponse.java index 831ccc34..1734dd6c 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionResponse.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionResponse.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.onap.sdc.workflow.api.types; import java.util.Collection; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/ErrorResponse.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/ErrorResponse.java index 1b8fb3c8..45f54341 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/ErrorResponse.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/ErrorResponse.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.onap.sdc.workflow.api.types; import lombok.AllArgsConstructor; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Paging.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Paging.java index 0a27e1e6..7e47f6d6 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Paging.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Paging.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.onap.sdc.workflow.api.types; import static org.onap.sdc.workflow.services.types.PagingConstants.MAX_LIMIT; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Sorting.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Sorting.java index f02a05fe..1a0c1a15 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Sorting.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/Sorting.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.onap.sdc.workflow.api.types; import java.util.Arrays; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/UnexpectedErrorResponse.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/UnexpectedErrorResponse.java index fbc5ab39..8cf513a2 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/UnexpectedErrorResponse.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/UnexpectedErrorResponse.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.onap.sdc.workflow.api.types; import lombok.Getter; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java index 18ed50c5..51e75edf 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/VersionStatesFormatter.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.onap.sdc.workflow.api.types; import java.util.Arrays; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/dto/ArtifactDeliveriesRequestDto.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/dto/ArtifactDeliveriesRequestDto.java index e3dc212a..2ec272fc 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/dto/ArtifactDeliveriesRequestDto.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/dto/ArtifactDeliveriesRequestDto.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.onap.sdc.workflow.api.types.dto; import lombok.Data; @@ -37,7 +38,7 @@ public class ArtifactDeliveriesRequestDto { public ArtifactDeliveriesRequestDto(){ } - public ArtifactDeliveriesRequestDto(String method, String endpoint){ + public ArtifactDeliveriesRequestDto(String method, String endpoint) { this.method = method; this.endpoint = endpoint; } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicates.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicates.java index ca4932ac..296e4387 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicates.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicates.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.onap.sdc.workflow.api.validation; import java.lang.annotation.Documented; @@ -13,6 +29,7 @@ import javax.validation.Payload; @Documented @Constraint(validatedBy = {NoDuplicatesValidator.class}) public @interface NoDuplicates { + String message(); Class<?>[] groups() default {}; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicatesValidator.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicatesValidator.java index 13bbf0e9..2020bb83 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicatesValidator.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/validation/NoDuplicatesValidator.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.onap.sdc.workflow.api.validation; import java.util.Collection; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ApplicationConfigurer.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ApplicationConfigurer.java new file mode 100644 index 00000000..e631a12c --- /dev/null +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ApplicationConfigurer.java @@ -0,0 +1,35 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.sdc.workflow.server.config; + +import org.openecomp.sdc.logging.servlet.spring.LoggingInterceptor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class ApplicationConfigurer implements WebMvcConfigurer { + + @Autowired + LoggingInterceptor loggingInterceptor; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(loggingInterceptor); + } +} diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/LoggingInterceptorConfig.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/LoggingInterceptorConfig.java new file mode 100644 index 00000000..53dbda59 --- /dev/null +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/LoggingInterceptorConfig.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.sdc.workflow.server.config; + +import org.openecomp.sdc.logging.servlet.HttpHeader; +import org.openecomp.sdc.logging.servlet.spring.LoggingInterceptor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class LoggingInterceptorConfig { + + @Value("${onap.logging.requestIdHeader}") + private String[] loggingRequestIdHeaders; + + @Value("${onap.logging.partnerNameHeader}") + private String[] loggingPartnerNameHeader; + + @Bean + public LoggingInterceptor createLoggingInterceptor() { + return new LoggingInterceptor(new HttpHeader(loggingRequestIdHeaders), + new HttpHeader(loggingPartnerNameHeader)); + } +} diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java index f17cea1f..a2eca63a 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/SwaggerConfig.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.onap.sdc.workflow.server.config; import static springfox.documentation.builders.PathSelectors.regex; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ZusammenConfig.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ZusammenConfig.java index 092c3464..23e8643b 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ZusammenConfig.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/config/ZusammenConfig.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.onap.sdc.workflow.server.config; import javax.annotation.PostConstruct; @@ -19,7 +35,7 @@ public class ZusammenConfig { private String cassandraAuth; @PostConstruct - public void init(){ + public void init() { System.setProperty("cassandra.nodes", cassandraAddress); System.setProperty("cassandra.user", cassandraUser); System.setProperty("cassandra.password", cassandraPassword); diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java index 28838327..e9742fcd 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/server/filters/SessionContextFilter.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.onap.sdc.workflow.server.filters; import java.io.IOException; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStatusModificationException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStatusModificationException.java index 7264682a..4eb8af42 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStatusModificationException.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionStatusModificationException.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.onap.sdc.workflow.services.exceptions; import org.openecomp.sdc.versioning.dao.types.VersionStatus; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionValidationException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionValidationException.java index bd7d61f2..815bc0b2 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionValidationException.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionValidationException.java @@ -1,6 +1,22 @@ +/* + * Copyright © 2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.onap.sdc.workflow.services.exceptions; -public class VersionValidationException extends RuntimeException{ +public class VersionValidationException extends RuntimeException { private static final String MSG = "Error creating or modifying version for workflow with id %s: %s"; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java index f312f7b4..f7df4474 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/Workflow.java @@ -17,6 +17,9 @@ package org.onap.sdc.workflow.services.types; +import static org.onap.sdc.workflow.services.types.WorkflowValidationConstants.MAX_LENGTH; +import static org.onap.sdc.workflow.services.types.WorkflowValidationConstants.MIN_LENGTH; + import java.util.Collection; import java.util.Set; import javax.validation.constraints.NotBlank; @@ -29,9 +32,9 @@ import lombok.Data; public class Workflow { private String id; - @NotBlank(message = "Workflow name may not be blank") - @Size(max = 80, message = "Workflow name must be less than 80 characters") - @Pattern(regexp = "[A-Za-z0-9_ ]+", message = "Workflow name must contain only letters, digits and underscores") + @NotBlank(message = "Workflow name may not be blank.") + @Size(min = MIN_LENGTH, max = MAX_LENGTH, message = "Workflow name must be at least " + MIN_LENGTH + " characters, and no more than " + MAX_LENGTH +" characters.") + @Pattern(regexp = "[A-Za-z0-9_ ]+", message = "Workflow name must contain only letters, digits and underscores.") private String name; private String description; private Set<WorkflowVersionState> versionStates; diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/WorkflowValidationConstants.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/WorkflowValidationConstants.java new file mode 100644 index 00000000..c88f36c6 --- /dev/null +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/types/WorkflowValidationConstants.java @@ -0,0 +1,7 @@ +package org.onap.sdc.workflow.services.types; + +public class WorkflowValidationConstants { + + public static final int MAX_LENGTH = 80; + public static final int MIN_LENGTH = 6; +} diff --git a/workflow-designer-be/src/main/resources/application-dev.properties b/workflow-designer-be/src/main/resources/application-dev.properties index 897b0422..12a99021 100644 --- a/workflow-designer-be/src/main/resources/application-dev.properties +++ b/workflow-designer-be/src/main/resources/application-dev.properties @@ -25,4 +25,8 @@ spring.data.cassandra.password=${CS_PASSWORD:} zusammen.cassandra.isAuthenticate=${CS_AUTHENTICATE:false} #Actuators -management.endpoint.health.show-details=always
\ No newline at end of file +management.endpoint.health.show-details=always + +#Headers are comma separated list +onap.logging.requestIdHeader=X-ECOMP-RequestID,X-ONAP-RequestID +onap.logging.partnerNameHeader=USER_ID
\ No newline at end of file diff --git a/workflow-designer-be/src/main/resources/application.properties b/workflow-designer-be/src/main/resources/application.properties index 64b58fd5..5fa56d82 100644 --- a/workflow-designer-be/src/main/resources/application.properties +++ b/workflow-designer-be/src/main/resources/application.properties @@ -29,4 +29,8 @@ spring.data.cassandra.password=${CS_PASSWORD:} zusammen.cassandra.isAuthenticate=${CS_AUTHENTICATE:true} #Actuators -management.endpoint.health.show-details=always
\ No newline at end of file +management.endpoint.health.show-details=always + +#Headers are comma separated list +onap.logging.requestIdHeader=X-ECOMP-RequestID,X-ONAP-RequestID +onap.logging.partnerNameHeader=USER_ID
\ No newline at end of file diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java index da452125..f8f86f1f 100644 --- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java @@ -10,6 +10,8 @@ import static org.onap.sdc.workflow.TestUtil.createWorkflow; import static org.onap.sdc.workflow.api.RestParams.USER_ID_HEADER; import static org.onap.sdc.workflow.services.types.PagingConstants.DEFAULT_LIMIT; import static org.onap.sdc.workflow.services.types.PagingConstants.DEFAULT_OFFSET; +import static org.onap.sdc.workflow.services.types.WorkflowValidationConstants.MAX_LENGTH; +import static org.onap.sdc.workflow.services.types.WorkflowValidationConstants.MIN_LENGTH; import static org.springframework.http.MediaType.APPLICATION_JSON; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; @@ -198,7 +200,7 @@ public class WorkflowControllerTest { mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON) .content(JsonUtil.object2Json(reqWorkflow))).andDo(print()) .andExpect(status().isBadRequest()).andExpect( - jsonPath("$.message", is("Workflow name must contain only letters, digits and underscores"))); + jsonPath("$.message", is("Workflow name must contain only letters, digits and underscores."))); } @Test @@ -207,8 +209,7 @@ public class WorkflowControllerTest { reqWorkflow.setName(" "); mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON) .content(JsonUtil.object2Json(reqWorkflow))).andDo(print()) - .andExpect(status().isBadRequest()).andExpect( - jsonPath("$.message", is("Workflow name may not be blank"))); + .andExpect(status().isBadRequest()); } @Test @@ -217,8 +218,7 @@ public class WorkflowControllerTest { reqWorkflow.setName(null); mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON) .content(JsonUtil.object2Json(reqWorkflow))).andDo(print()) - .andExpect(status().isBadRequest()).andExpect( - jsonPath("$.message", is("Workflow name may not be blank"))); + .andExpect(status().isBadRequest()); } @Test @@ -227,8 +227,27 @@ public class WorkflowControllerTest { reqWorkflow.setName(""); mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON) .content(JsonUtil.object2Json(reqWorkflow))).andDo(print()) + .andExpect(status().isBadRequest()); + } + + @Test + public void shouldThrowExceptionWhenWorkflowNameMoreThanMax() throws Exception { + Workflow reqWorkflow = new Workflow(); + reqWorkflow.setName("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON) + .content(JsonUtil.object2Json(reqWorkflow))).andDo(print()) + .andExpect(status().isBadRequest()).andExpect( + jsonPath("$.message", is("Workflow name must be at least " + MIN_LENGTH + " characters, and no more than " + MAX_LENGTH + " characters."))); + } + + @Test + public void shouldThrowExceptionWhenWorkflowNameLessThanMin() throws Exception { + Workflow reqWorkflow = new Workflow(); + reqWorkflow.setName("AAA"); + mockMvc.perform(post(RestPath.getWorkflowsPath()).header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON) + .content(JsonUtil.object2Json(reqWorkflow))).andDo(print()) .andExpect(status().isBadRequest()).andExpect( - jsonPath("$.message", is("Workflow name may not be blank"))); + jsonPath("$.message", is("Workflow name must be at least " + MIN_LENGTH + " characters, and no more than " + MAX_LENGTH + " characters."))); } private void mockManagerList3() { diff --git a/workflow-designer-ui/src/main/webapp/WEB-INF/web.xml b/workflow-designer-ui/src/main/webapp/WEB-INF/web.xml index 8cbfd89b..a58e1274 100644 --- a/workflow-designer-ui/src/main/webapp/WEB-INF/web.xml +++ b/workflow-designer-ui/src/main/webapp/WEB-INF/web.xml @@ -14,6 +14,7 @@ <servlet-mapping> <servlet-name>Transparent Proxy</servlet-name> <url-pattern>/wf/*</url-pattern> + <url-pattern>/v1.0/activity-spec/*</url-pattern> </servlet-mapping> -</web-app>
\ No newline at end of file +</web-app> |