X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=models-sim%2Fmodels-sim-dmaap%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fmodels%2Fsim%2Fdmaap%2Frest%2FDmaapSimRestControllerV1Test.java;fp=models-sim%2Fmodels-sim-dmaap%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fmodels%2Fsim%2Fdmaap%2Frest%2FDmaapSimRestControllerV1Test.java;h=0000000000000000000000000000000000000000;hb=49f07db935d114b72a44e446867b16262dd552aa;hp=fd9397e340a0421aee317a9ff59370a69482d1ab;hpb=71be21fd5b9b52c613bb855f00a79a51e81906dd;p=policy%2Fmodels.git diff --git a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1Test.java b/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1Test.java deleted file mode 100644 index fd9397e34..000000000 --- a/models-sim/models-sim-dmaap/src/test/java/org/onap/policy/models/sim/dmaap/rest/DmaapSimRestControllerV1Test.java +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. - * ================================================================================ - * 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.policy.models.sim.dmaap.rest; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; - -import jakarta.ws.rs.core.Response; -import java.io.File; -import java.util.Arrays; -import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.common.utils.coder.Coder; -import org.onap.policy.common.utils.coder.CoderException; -import org.onap.policy.common.utils.coder.StandardCoder; -import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup; -import org.onap.policy.models.sim.dmaap.provider.DmaapSimProvider; - -public class DmaapSimRestControllerV1Test { - private static final int LIMIT = 5; - private static final String TOPIC = "my-topic"; - private static final String TOPIC2 = "my-topic-B"; - private static final String MESSAGE = "my-message"; - private static final String MESSAGE2 = "my-message-B"; - private static final String CONSUMER = "my-consumer"; - private static final String CONSUMER_ID = "my-id"; - - private static final Coder coder = new StandardCoder(); - - private DmaapSimRestControllerV1 rest; - - /** - * Creates the controller. - * - * @throws CoderException if the parameters cannot be loaded - */ - @Before - public void setUp() throws CoderException { - DmaapSimParameterGroup params = coder.decode(new File("src/test/resources/parameters/NormalParameters.json"), - DmaapSimParameterGroup.class); - DmaapSimProvider.setInstance(new DmaapSimProvider(params)); - rest = new DmaapSimRestControllerV1(); - } - - @Test - public void test() { - Response resp = rest.getDmaapMessage(TOPIC, CONSUMER, CONSUMER_ID, LIMIT, 0); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - assertEquals("[]", resp.getEntity().toString()); - - // add some messages - resp = rest.postDmaapMessage(TOPIC, Arrays.asList(MESSAGE, MESSAGE2)); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - assertEquals(2, getCount(resp)); - - resp = rest.postDmaapMessage(TOPIC2, Arrays.asList(MESSAGE, MESSAGE2, MESSAGE)); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - assertEquals(3, getCount(resp)); - - // hadn't registered with topic 2 so nothing expected from there - resp = rest.getDmaapMessage(TOPIC2, CONSUMER, CONSUMER_ID, LIMIT, 0); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - assertEquals("[]", resp.getEntity().toString()); - - // now read from topic 1 - resp = rest.getDmaapMessage(TOPIC, CONSUMER, CONSUMER_ID, LIMIT, 0); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - assertEquals("[my-message, my-message-B]", resp.getEntity().toString()); - - // verify getDmaapTopics - resp = rest.getDmaapTopics(); - assertEquals(Response.Status.OK.getStatusCode(), resp.getStatus()); - assertThat(resp.getEntity().toString()).contains("POLICY-PDP-PAP"); - } - - private int getCount(Response resp) { - @SuppressWarnings("unchecked") - Map map = (Map) resp.getEntity(); - - return (int) map.get("count"); - } - -}