* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 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.
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler;
+@RunWith(MockitoJUnitRunner.class)
public class BidirectionalTopicActorTest {
private static final String ACTOR = "my-actor";
@Mock
private BidirectionalTopicHandler handler2;
- private BidirectionalTopicActor actor;
+ private BidirectionalTopicActor<BidirectionalTopicActorParams> actor;
/**
*/
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
-
actor = new MyActor();
actor.configure(Util.translateToMap(ACTOR, makeParams()));
}
public void testMakeOperatorParameters() {
BidirectionalTopicActorParams params = makeParams();
- final BidirectionalTopicActor prov = new BidirectionalTopicActor(ACTOR);
+ final BidirectionalTopicActor<BidirectionalTopicActorParams> prov =
+ new BidirectionalTopicActor<>(ACTOR, BidirectionalTopicActorParams.class);
Function<String, Map<String, Object>> maker =
prov.makeOperatorParameters(Util.translateToMap(prov.getName(), params));
new TreeMap<>(maker.apply("operB")).toString());
// with invalid actor parameters
- params.setOperation(null);
- assertThatThrownBy(() -> prov.makeOperatorParameters(Util.translateToMap(prov.getName(), params)))
+ params.setOperations(null);
+ Map<String, Object> map = Util.translateToMap(prov.getName(), params);
+ assertThatThrownBy(() -> prov.makeOperatorParameters(map))
.isInstanceOf(ParameterValidationRuntimeException.class);
}
@Test
public void testMakeTopicHandler() {
// use a real actor
- actor = new BidirectionalTopicActor(ACTOR);
+ actor = new BidirectionalTopicActor<>(ACTOR, BidirectionalTopicActorParams.class);
handler1 = actor.getTopicHandler(MY_SINK, MY_SOURCE1);
handler2 = actor.getTopicHandler(MY_SINK, MY_SOURCE2);
params.setTimeoutSec(TIMEOUT);
// @formatter:off
- params.setOperation(Map.of(
+ params.setOperations(Map.of(
"operA", Map.of(),
"operB", Map.of("sourceTopic", "topicB")));
// @formatter:on
return params;
}
- private class MyActor extends BidirectionalTopicActor {
+ private class MyActor extends BidirectionalTopicActor<BidirectionalTopicActorParams> {
public MyActor() {
- super(ACTOR);
+ super(ACTOR, BidirectionalTopicActorParams.class);
}
@Override