From 8305b22009a8f257e91585f91cfa5d5ed6bc4164 Mon Sep 17 00:00:00 2001 From: Joss Armstrong Date: Tue, 5 Mar 2019 14:55:41 +0000 Subject: Test coverage in RequestValidator Increased coverage from 61% to 79% Issue-ID: APPC-1436 Change-Id: I4a372d40b5593f32685b09c5240654dab0aee968 Signed-off-by: Joss Armstrong --- .../design/dbervices/RequestValidatorTest.java | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/dbervices/RequestValidatorTest.java (limited to 'appc-inbound/appc-design-services') diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/dbervices/RequestValidatorTest.java b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/dbervices/RequestValidatorTest.java new file mode 100644 index 000000000..c0ced1f68 --- /dev/null +++ b/appc-inbound/appc-design-services/provider/src/test/java/org/onap/appc/design/dbervices/RequestValidatorTest.java @@ -0,0 +1,72 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2019 Ericsson + * ================================================================================ + * 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. + * + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.design.dbervices; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mockito; +import org.onap.appc.design.services.util.DesignServiceConstants; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import java.io.IOException; + +public class RequestValidatorTest { + + + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + + @Test + public void testValidateArtifactWithVersion() throws RequestValidationException, IOException { + RequestValidator.validate(DesignServiceConstants.GETAPPCTIMESTAMPUTC, "{}"); + expectedEx.expect(RequestValidationException.class); + expectedEx.expectMessage("Missing input parameter :-artifact-contents -:"); + RequestValidator.validate(DesignServiceConstants.UPLOADADMINARTIFACT, "{\"" + + DesignServiceConstants.ARTIFACT_NAME + "\":\"reference\", \"" + + DesignServiceConstants.ARTIFACT_VERSOIN + "\":\"VERSION\"}"); + } + + @Test + public void testValidateArtifact() throws RequestValidationException, IOException { + RequestValidator.validate(DesignServiceConstants.GETAPPCTIMESTAMPUTC, "{}"); + expectedEx.expect(RequestValidationException.class); + expectedEx.expectMessage("Missing input parameter :-artifact-version -:"); + RequestValidator.validate(DesignServiceConstants.UPLOADADMINARTIFACT, "{\"" + + DesignServiceConstants.ARTIFACT_NAME + "\":\"reference\"}"); + } + + @Test + public void testValidateVnf() throws RequestValidationException, IOException { + expectedEx.expect(RequestValidationException.class); + expectedEx.expectMessage("Missing input parameter :-vnf-type -:"); + RequestValidator.validate(DesignServiceConstants.CHECKVNF, "{}"); + } + + @Test + public void testValidateInvalidAction() throws RequestValidationException, IOException { + expectedEx.expect(RequestValidationException.class); + expectedEx.expectMessage(" Action INVALID_ACTION not found while processing request "); + RequestValidator.validate("INVALID_ACTION", "{}"); + } +} -- cgit 1.2.3-korg