+++ /dev/null
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2024-2025 OpenInfra Foundation Europe. All rights reserved.
- * ================================================================================
- * 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.impl.datajobs.subscription.cache;
-
-import com.hazelcast.config.MapConfig;
-import com.hazelcast.map.IMap;
-import java.util.Map;
-import org.onap.cps.impl.cache.HazelcastCacheConfig;
-import org.onap.cps.ncmp.impl.datajobs.subscription.models.DmiCmSubscriptionDetails;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class CmSubscriptionConfig extends HazelcastCacheConfig {
-
- private static final MapConfig cmNotificationSubscriptionCacheMapConfig =
- createGenericMapConfig("cmNotificationSubscriptionCacheMapConfig");
-
- /**
- * Distributed instance of cm notification subscription information
- * cache that contains subscription id as key
- * and incoming event data processed per dmi plugin.
- *
- * @return configured map of subscription events.
- */
- @Bean
- public IMap<String, Map<String, DmiCmSubscriptionDetails>> cmNotificationSubscriptionCache() {
- return getOrCreateHazelcastInstance(cmNotificationSubscriptionCacheMapConfig).getMap(
- "cmNotificationSubscriptionCache");
- }
-}
'data node selector for other dmi' | 'someOtherDmi' || 0
}
- def 'Log update when subscription status is REJECTED'() {
+ def 'Ignoring data node selector with no FDN prefix.'() {
+ given: 'the persistence service returns data node selector with no FDN prefix'
+ def myDataNodeSelectors = ['/noFdnPrefix'].asList()
+ mockCmSubscriptionPersistenceService.getInactiveDataNodeSelectors('someSubId') >> myDataNodeSelectors
+ when: 'method to update subscription status is called'
+ objectUnderTest.updateCmSubscriptionStatus('someSubId', 'someDmiServiceName', ACCEPTED)
+ then: 'update status is not delegated to persistence service'
+ 0 * mockCmSubscriptionPersistenceService.updateCmSubscriptionStatus('/noFdnPrefix', ACCEPTED)
+ }
+
+ def 'Update subscription status to REJECTED'() {
given: 'dmi service name and subscription id'
def myDmi = 'myDmi'
def mySubscriptionId = 'mySubscriptionId'
package org.onap.cps.ncmp.impl.datajobs.subscription.ncmp
-import ch.qos.logback.classic.Level
-import ch.qos.logback.classic.Logger
-import ch.qos.logback.classic.spi.ILoggingEvent
-import ch.qos.logback.core.read.ListAppender
import com.fasterxml.jackson.databind.ObjectMapper
+import org.onap.cps.ncmp.impl.datajobs.subscription.client_to_ncmp.DataJob
import org.onap.cps.ncmp.impl.datajobs.subscription.client_to_ncmp.DataJobSubscriptionOperationInEvent
+import org.onap.cps.ncmp.impl.datajobs.subscription.client_to_ncmp.Event
import org.onap.cps.ncmp.impl.utils.JexParser
import org.onap.cps.ncmp.utils.TestUtils
-import org.slf4j.LoggerFactory
import spock.lang.Specification
class NcmpInEventConsumerSpec extends Specification {
1 * mockCmSubscriptionHandler.deleteSubscription("myDataJobId")
}
+ def 'Consuming subscription request with unknown event type.'() {
+ given: 'a subscription event with invalid event type'
+ def invalidEvent = new DataJobSubscriptionOperationInEvent(event:new Event(dataJob: new DataJob(id:'someId')), eventType: 'invalidEventType')
+ when: 'the event is consumed'
+ objectUnderTest.consumeSubscriptionEvent(invalidEvent)
+ then: 'no error thrown'
+ noExceptionThrown()
+ and: 'request was not delegated to be handled as CREATE or DELETE'
+ 0 * mockCmSubscriptionHandler.deleteSubscription(_)
+ 0 * mockCmSubscriptionHandler.createSubscription(_)
+ }
+
def getDataNodeSelectorsAsXpaths(event) {
return JexParser.toXpaths(event.event.dataJob.productionJobDefinition.targetSelector.dataNodeSelector)
}