Fix @Ignore test 45/136645/2
authorleventecsanyi <levente.csanyi@est.tech>
Fri, 24 Nov 2023 10:40:19 +0000 (11:40 +0100)
committerleventecsanyi <levente.csanyi@est.tech>
Fri, 24 Nov 2023 13:55:48 +0000 (14:55 +0100)
  - removed EventPublisherSpec
  - fixed toDataStores test

Issue-ID: CPS-1874
Signed-off-by: leventecsanyi <levente.csanyi@est.tech>
Change-Id: I857c7bcb0aa52604da6692545456769a4ec151ec

cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/mapper/CmHandleStateMapperSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/EventPublisherSpec.groovy [deleted file]

index f394f91..b5f7f0e 100644 (file)
@@ -28,9 +28,7 @@ import org.onap.cps.ncmp.api.impl.inventory.CmHandleState
 import org.onap.cps.ncmp.api.impl.inventory.CompositeStateBuilder
 import org.onap.cps.ncmp.rest.model.CmHandleCompositeState
 import org.onap.cps.ncmp.api.impl.inventory.DataStoreSyncState
-import spock.lang.Ignore
 import spock.lang.Specification
-
 import java.time.OffsetDateTime
 import java.time.ZoneOffset
 import java.time.format.DateTimeFormatter
@@ -62,10 +60,9 @@ class CmHandleStateMapperSpec extends Specification {
             assert result.dataSyncState.operational.getSyncState() != null
     }
 
-    @Ignore
     def 'Handling null state.'() {
         expect: 'converting null returns null'
-            objectUnderTest.toDataStores(null) == null
+            CmHandleStateMapper.toDataStores(null) == null
     }
 
     def 'Internal to External Lock Reason Mapping of #scenario'() {
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/EventPublisherSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/EventPublisherSpec.groovy
deleted file mode 100644 (file)
index 0e06383..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * ============LICENSE_START========================================================
- * 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.
- *
- *  SPDX-License-Identifier: Apache-2.0
- *  ============LICENSE_END=========================================================
- */
-
-package org.onap.cps.ncmp.api.impl.events
-
-import ch.qos.logback.classic.Level
-import ch.qos.logback.classic.Logger
-import ch.qos.logback.core.read.ListAppender
-import org.apache.kafka.clients.producer.ProducerRecord
-import org.apache.kafka.clients.producer.RecordMetadata
-import org.apache.kafka.common.TopicPartition
-import org.onap.cps.ncmp.init.CmDataSubscriptionModelLoader
-import org.slf4j.LoggerFactory
-import org.springframework.kafka.support.SendResult
-import spock.lang.Ignore
-import spock.lang.Specification
-
-class EventPublisherSpec extends Specification {
-
-    def objectUnderTest = new EventsPublisher(null, null)
-    def logger = (Logger) LoggerFactory.getLogger(objectUnderTest.getClass())
-    def loggingListAppender
-
-    void setup() {
-        logger.setLevel(Level.DEBUG)
-        loggingListAppender = new ListAppender()
-        logger.addAppender(loggingListAppender)
-        loggingListAppender.start()
-    }
-
-    void cleanup() {
-        ((Logger) LoggerFactory.getLogger(CmDataSubscriptionModelLoader.class)).detachAndStopAllAppenders()
-    }
-
-    @Ignore
-    def 'Callback handling on success.'() {
-        given: 'a send result'
-            def producerRecord = new ProducerRecord('topic-1', 'my value')
-            def topicPartition = new TopicPartition('topic-2', 0)
-            def recordMetadata = new RecordMetadata(topicPartition, 0, 0, 0, 0, 0)
-            def sendResult = new SendResult(producerRecord, recordMetadata)
-        when: 'the callback handler processes success'
-            def callbackHandler = objectUnderTest.handleCallback('topic-3')
-            callbackHandler.onSuccess(sendResult)
-        then: 'an event is logged with level DEBUG'
-            def loggingEvent = getLoggingEvent()
-            loggingEvent.level == Level.DEBUG
-        and: 'it contains the topic (from the record metadata) and the "value" (from the producer record)'
-            loggingEvent.formattedMessage.contains('topic-2')
-            loggingEvent.formattedMessage.contains('my value')
-    }
-
-
-    @Ignore
-    def 'Callback handling on failure.'() {
-        when: 'the callback handler processes a failure'
-            def callbackHandler = objectUnderTest.handleCallback('my topic')
-            callbackHandler.onFailure(new Exception('my exception'))
-        then: 'an event is logged with level ERROR'
-            def loggingEvent = getLoggingEvent()
-            loggingEvent.level == Level.ERROR
-        and: 'it contains the topic and exception message'
-            loggingEvent.formattedMessage.contains('my topic')
-            loggingEvent.formattedMessage.contains('my exception')
-    }
-
-    def getLoggingEvent() {
-        return loggingListAppender.list[0]
-    }
-
-
-}