import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
import org.onap.policy.controlloop.actor.cds.request.CdsActionRequest;
+import org.onap.policy.controlloop.actorserviceprovider.Operator;
import org.onap.policy.controlloop.actorserviceprovider.impl.ActorImpl;
import org.onap.policy.controlloop.policy.Policy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * CDS Actor service-provider implementation. This is a deploy dark feature for El-Alto
- * release.
+ * CDS is an unusual actor in that it uses a single, generic operator to initiate all
+ * operation types. The action taken is always the same, only the operation name changes.
*/
public class CdsActorServiceProvider extends ActorImpl {
addOperator(new GrpcOperator(CdsActorConstants.CDS_ACTOR, GrpcOperation.NAME, GrpcOperation::new));
}
+ @Override
+ public Operator getOperator(String name) {
+ /*
+ * All operations are managed by the same operator, regardless of the name.
+ */
+ return super.getOperator(GrpcOperation.NAME);
+ }
+
// TODO old code: remove lines down to **HERE**
/**
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2020 AT&T Intellectual Property. 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.
@Getter
public class GrpcOperation extends OperationPartial {
- public static final String NAME = "gRPC";
+ public static final String NAME = "any";
private CdsProcessorGrpcClient client;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import org.onap.policy.controlloop.actor.cds.CdsActorServiceProvider.CdsActorServiceManager;
import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants;
import org.onap.policy.controlloop.actor.test.BasicActor;
+import org.onap.policy.controlloop.actorserviceprovider.Operator;
import org.onap.policy.controlloop.policy.Policy;
public class CdsActorServiceProviderTest extends BasicActor {
verifyActorService(CdsActorConstants.CDS_ACTOR, "service.yaml");
}
+ @Test
+ public void testGetOperator() {
+ CdsActorServiceProvider sp = new CdsActorServiceProvider();
+
+ // should always return the same operator regardless of the name
+ Operator oper = sp.getOperator("unknown");
+ assertNotNull(oper);
+ assertSame(oper, sp.getOperator("another"));
+ }
+
@Test
public void testConstructRequestWhenMissingCdsParamsInPolicyPayload() {
policy.setPayload(new HashMap<>());
#
actors:
CDS:
- gRPC:
+ any:
timeout: 10
port: 6700
host: my-host