Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
7bc15c3
api,server,ui: weebhoks feature
shwstppr Jan 16, 2024
8442350
fix
shwstppr Feb 12, 2024
a69192c
fix
shwstppr Feb 13, 2024
af388a0
changes
shwstppr Feb 13, 2024
d17ded0
registry of message busses
DaanHoogland Sep 21, 2023
fa874ed
test bus
shwstppr Feb 13, 2024
75a56f7
refactor
shwstppr Feb 13, 2024
0c2a5c7
test
shwstppr Feb 13, 2024
d82863b
fix and refactor
shwstppr Feb 13, 2024
d273921
Merge branch 'message-buses' into add-feature-webhooks
shwstppr Feb 13, 2024
f74ffee
changes for webhook dispatch history
shwstppr Feb 14, 2024
a06b8f6
changes, initial ui
shwstppr Feb 14, 2024
d2c3d40
improvements
shwstppr Feb 15, 2024
23621eb
changes for account webhook cleanup
shwstppr Feb 16, 2024
d4bd086
fix remaining event bus usage
shwstppr Feb 16, 2024
3821fac
changes for testing webhook dispatch
shwstppr Feb 16, 2024
e8f4c1c
wip
shwstppr Feb 16, 2024
291ead5
fix test
shwstppr Feb 16, 2024
8a88be7
make element
shwstppr Feb 19, 2024
1072909
missing
shwstppr Feb 19, 2024
4952ac2
Merge remote-tracking branch 'apache/main' into add-feature-webhooks
shwstppr Feb 19, 2024
a1a10ec
buid fix
shwstppr Feb 19, 2024
cf2eb1f
fix lint
shwstppr Feb 19, 2024
e7911a8
Merge remote-tracking branch 'apache/main' into add-feature-webhooks
shwstppr Feb 19, 2024
684f6d6
changes for project delete check
shwstppr Feb 19, 2024
2d097dd
fix
shwstppr Feb 19, 2024
02a1196
add collapse in create
shwstppr Feb 19, 2024
30f4c48
ui fix and refactor for eventditributor publish
shwstppr Feb 19, 2024
a89a428
update org.json and add json validation
shwstppr Feb 19, 2024
2debb85
schema fixes
shwstppr Feb 20, 2024
c7caf30
wordings
shwstppr Feb 21, 2024
5c04e87
ui: improve progress button
shwstppr Feb 21, 2024
e4e5ff0
ui improvements
shwstppr Feb 23, 2024
05f0590
remove unrelated change
shwstppr Feb 23, 2024
ac651e2
search and count
shwstppr Feb 23, 2024
3e3ca82
add payloadurl in info
shwstppr Feb 23, 2024
8dc662d
Merge branch 'main' into add-feature-webhooks
DaanHoogland Feb 26, 2024
85059c5
positive progress
shwstppr Feb 26, 2024
10a5e32
fix hmac key
shwstppr Feb 26, 2024
5cde6e8
create webhook form fixes
shwstppr Feb 26, 2024
819eb47
refactor, address feedback
shwstppr Feb 27, 2024
c70df5c
indentation
shwstppr Feb 27, 2024
64b52bf
fix filters
shwstppr Feb 28, 2024
07eae2f
remove test eventbus
shwstppr Feb 28, 2024
85edf96
default scope be Local
shwstppr Feb 28, 2024
fcd161d
add lifecycle smoke test
shwstppr Feb 28, 2024
dd522ca
add test for webhook deliveries
shwstppr Feb 28, 2024
7bc36ae
refactor
shwstppr Feb 29, 2024
3a739d4
fix lint
shwstppr Feb 29, 2024
27e683e
refactor - losgs and others
shwstppr Mar 4, 2024
38f3adc
unit tests
shwstppr Mar 4, 2024
31d85ef
Merge remote-tracking branch 'apache/main' into add-feature-webhooks
shwstppr Mar 4, 2024
2a4226a
fix lint
shwstppr Mar 4, 2024
dc79745
build fix
shwstppr Mar 4, 2024
e40d7ac
smoke test fix, log refactor
shwstppr Mar 5, 2024
398bc10
get bean from all components
shwstppr Mar 6, 2024
980dfb5
ui: missing label
shwstppr Mar 7, 2024
256f7a6
Merge remote-tracking branch 'apache/main' into add-feature-webhooks
shwstppr Mar 8, 2024
52b4fc3
address review comments
shwstppr Mar 14, 2024
4353a69
Merge remote-tracking branch 'apache/main' into add-feature-webhooks
shwstppr Mar 14, 2024
b054e0c
Merge remote-tracking branch 'apache/main' into add-feature-webhooks
shwstppr Apr 2, 2024
6a3949a
add some more tests
shwstppr Apr 8, 2024
ca83c0a
lint
shwstppr Apr 8, 2024
623496c
rename setting
shwstppr Apr 8, 2024
9bd4f1e
upgrade: move 4.19.0->4.20.0 to 4.19.1->4.20.0
weizhouapache Apr 8, 2024
426c120
fix test delivery layout
shwstppr Apr 15, 2024
ddadf22
fix webhook secret display
shwstppr Apr 15, 2024
54ad344
add http to payloadurl when no scheme
shwstppr Apr 15, 2024
9956375
allow removing secretkey for webhook
shwstppr Apr 15, 2024
8c5f2a6
fix update sslverification
shwstppr Apr 18, 2024
8a9039a
disallow same payload url for same account
shwstppr Apr 18, 2024
5c7b33e
fix delivery with url w/o scheme
shwstppr Apr 18, 2024
4f245b8
api: listApis should return params based on caller
shwstppr Apr 24, 2024
2748743
Merge branch 'main' into add-feature-webhooks
shwstppr Apr 29, 2024
e26432b
wip changes
shwstppr Apr 29, 2024
ef00a8c
Update engine/schema/src/main/resources/META-INF/db/schema-41900to420…
shwstppr Apr 30, 2024
8e1d53e
remove unique constraint for now
shwstppr Apr 30, 2024
3c9cca9
fixes
shwstppr May 1, 2024
7f54693
ui: add option to delete multiple deliveries
shwstppr May 1, 2024
21e051e
add filter for deliveries, delete api start/endtime support
shwstppr May 5, 2024
0497c5c
do not throw error when no deliveries removed
shwstppr May 5, 2024
36d0cad
Merge branch 'main' into 4.20-fix-upgrade-path-from-4191
weizhouapache May 7, 2024
67498fc
ui: fix deliveries table column sorting, time filter cancel
shwstppr May 7, 2024
12baadc
Merge remote-tracking branch 'apache/main' into add-feature-webhooks
shwstppr May 28, 2024
a75e138
Merge remote-tracking branch 'wei/4.20-fix-upgrade-path-from-4191' in…
shwstppr May 29, 2024
c67bf4c
Merge remote-tracking branch 'apache/main' into add-feature-webhooks
shwstppr Jun 3, 2024
757d113
remove isDebugEnabled wrapping
shwstppr Jun 5, 2024
4e72012
Merge remote-tracking branch 'apache/main' into add-feature-webhooks
shwstppr Jun 7, 2024
b15bba5
merge fix
shwstppr Jun 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ jobs:
smoke/test_migration
smoke/test_multipleips_per_nic
smoke/test_nested_virtualization
smoke/test_set_sourcenat",
smoke/test_set_sourcenat
smoke/test_webhook_lifecycle",
"smoke/test_network
smoke/test_network_acl
smoke/test_network_ipv6
Expand Down
23 changes: 17 additions & 6 deletions api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ public class ApiConstants {
public static final String END_IPV6 = "endipv6";
public static final String END_PORT = "endport";
public static final String ENTRY_TIME = "entrytime";
public static final String EVENT_ID = "eventid";
public static final String EVENT_TYPE = "eventtype";
public static final String EXPIRES = "expires";
public static final String EXTRA_CONFIG = "extraconfig";
public static final String EXTRA_DHCP_OPTION = "extradhcpoption";
Expand Down Expand Up @@ -209,6 +211,7 @@ public class ApiConstants {
public static final String HA_PROVIDER = "haprovider";
public static final String HA_STATE = "hastate";
public static final String HEALTH = "health";
public static final String HEADERS = "headers";
public static final String HIDE_IP_ADDRESS_USAGE = "hideipaddressusage";
public static final String HOST_ID = "hostid";
public static final String HOST_IDS = "hostids";
Expand Down Expand Up @@ -281,6 +284,7 @@ public class ApiConstants {
public static final String JOB_STATUS = "jobstatus";
public static final String KEEPALIVE_ENABLED = "keepaliveenabled";
public static final String KERNEL_VERSION = "kernelversion";
public static final String KEY = "key";
public static final String LABEL = "label";
public static final String LASTNAME = "lastname";
public static final String LAST_BOOT = "lastboottime";
Expand Down Expand Up @@ -355,6 +359,7 @@ public class ApiConstants {
public static final String SSHKEY_ENABLED = "sshkeyenabled";
public static final String PATH = "path";
public static final String PAYLOAD = "payload";
public static final String PAYLOAD_URL = "payloadurl";
public static final String POD_ID = "podid";
public static final String POD_NAME = "podname";
public static final String POD_IDS = "podids";
Expand Down Expand Up @@ -400,11 +405,9 @@ public class ApiConstants {
public static final String QUERY_FILTER = "queryfilter";
public static final String SCHEDULE = "schedule";
public static final String SCOPE = "scope";
public static final String SECRET_KEY = "usersecretkey";
public static final String SECONDARY_IP = "secondaryip";
public static final String SINCE = "since";
public static final String KEY = "key";
public static final String SEARCH_BASE = "searchbase";
public static final String SECONDARY_IP = "secondaryip";
public static final String SECRET_KEY = "secretkey";
public static final String SECURITY_GROUP_IDS = "securitygroupids";
public static final String SECURITY_GROUP_NAMES = "securitygroupnames";
public static final String SECURITY_GROUP_NAME = "securitygroupname";
Expand All @@ -422,15 +425,15 @@ public class ApiConstants {
public static final String SHOW_UNIQUE = "showunique";
public static final String SIGNATURE = "signature";
public static final String SIGNATURE_VERSION = "signatureversion";
public static final String SINCE = "since";
public static final String SIZE = "size";
public static final String SNAPSHOT = "snapshot";
public static final String SNAPSHOT_ID = "snapshotid";
public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid";
public static final String SNAPSHOT_TYPE = "snapshottype";
public static final String SNAPSHOT_QUIESCEVM = "quiescevm";
public static final String SOURCE_ZONE_ID = "sourcezoneid";
public static final String SUITABLE_FOR_VM = "suitableforvirtualmachine";
public static final String SUPPORTS_STORAGE_SNAPSHOT = "supportsstoragesnapshot";
public static final String SSL_VERIFICATION = "sslverification";
public static final String START_DATE = "startdate";
public static final String START_ID = "startid";
public static final String START_IP = "startip";
Expand All @@ -449,6 +452,9 @@ public class ApiConstants {
public static final String SYSTEM_VM_TYPE = "systemvmtype";
public static final String TAGS = "tags";
public static final String STORAGE_TAGS = "storagetags";
public static final String SUCCESS = "success";
public static final String SUITABLE_FOR_VM = "suitableforvirtualmachine";
public static final String SUPPORTS_STORAGE_SNAPSHOT = "supportsstoragesnapshot";
public static final String TARGET_IQN = "targetiqn";
public static final String TEMPLATE_FILTER = "templatefilter";
public static final String TEMPLATE_ID = "templateid";
Expand Down Expand Up @@ -482,6 +488,7 @@ public class ApiConstants {
public static final String USERNAME = "username";
public static final String USER_CONFIGURABLE = "userconfigurable";
public static final String USER_SECURITY_GROUP_LIST = "usersecuritygrouplist";
public static final String USER_SECRET_KEY = "usersecretkey";
public static final String USE_VIRTUAL_NETWORK = "usevirtualnetwork";
public static final String UPDATE_IN_SEQUENCE = "updateinsequence";
public static final String VALUE = "value";
Expand Down Expand Up @@ -561,6 +568,7 @@ public class ApiConstants {
public static final String ALLOCATION_STATE = "allocationstate";
public static final String MANAGED_STATE = "managedstate";
public static final String MANAGEMENT_SERVER_ID = "managementserverid";
public static final String MANAGEMENT_SERVER_NAME = "managementservername";
public static final String STORAGE = "storage";
public static final String STORAGE_ID = "storageid";
public static final String PING_STORAGE_SERVER_IP = "pingstorageserverip";
Expand Down Expand Up @@ -1121,6 +1129,9 @@ public class ApiConstants {

public static final String PARAMETER_DESCRIPTION_IS_TAG_A_RULE = "Whether the informed tag is a JS interpretable rule or not.";

public static final String WEBHOOK_ID = "webhookid";
public static final String WEBHOOK_NAME = "webhookname";

/**
* This enum specifies IO Drivers, each option controls specific policies on I/O.
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class UpdateUserCmd extends BaseCmd {
@Parameter(name = ApiConstants.CURRENT_PASSWORD, type = CommandType.STRING, description = "Current password that was being used by the user. You must inform the current password when updating the password.", acceptedOnAdminPort = false)
private String currentPassword;

@Parameter(name = ApiConstants.SECRET_KEY, type = CommandType.STRING, description = "The secret key for the user. Must be specified with userApiKey")
@Parameter(name = ApiConstants.USER_SECRET_KEY, type = CommandType.STRING, description = "The secret key for the user. Must be specified with userApiKey")
private String secretKey;

@Parameter(name = ApiConstants.TIMEZONE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class BucketResponse extends BaseResponseWithTagInformation implements Co
@Param(description = "Bucket Access Key")
private String accessKey;

@SerializedName(ApiConstants.SECRET_KEY)
@SerializedName(ApiConstants.USER_SECRET_KEY)
@Param(description = "Bucket Secret Key")
private String secretKey;

Expand Down
5 changes: 5 additions & 0 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,11 @@
<artifactId>cloud-mom-kafka</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-mom-webhook</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-framework-agent-lb</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@
</bean>

<bean id="hypervisorGurusRegistry"
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
<property name="excludeKey" value="hypervisor.gurus.exclude" />
</bean>

<bean id="vpcProvidersRegistry"
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
<property name="excludeKey" value="vpc.providers.exclude" />
Expand Down Expand Up @@ -358,4 +358,9 @@
</list>
</property>
</bean>

<bean id="eventBusRegistry"
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
<property name="excludeKey" value="event.buses.exclude" />
</bean>
</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

name=event
parent=core
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.

-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
>
<bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
<property name="registry" ref="eventBusRegistry" />
<property name="typeClass" value="org.apache.cloudstack.framework.events.EventBus" />
</bean>

</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@
import javax.annotation.PostConstruct;
import javax.inject.Inject;

import org.apache.commons.collections.MapUtils;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;

import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.framework.events.Event;
import org.apache.cloudstack.framework.events.EventBus;
import org.apache.cloudstack.framework.events.EventBusException;
import org.apache.cloudstack.framework.events.EventDistributor;
import org.apache.commons.collections.MapUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;

import com.cloud.dc.DataCenterVO;
import com.cloud.dc.dao.DataCenterDao;
Expand All @@ -50,6 +49,7 @@ public class UsageEventUtils {
protected static Logger LOGGER = LogManager.getLogger(UsageEventUtils.class);
protected static EventBus s_eventBus = null;
protected static ConfigurationDao s_configDao;
private static EventDistributor eventDistributor;

@Inject
UsageEventDao usageEventDao;
Expand Down Expand Up @@ -207,9 +207,9 @@ private static void publishUsageEvent(String usageEventType, Long accountId, Lon
if( !configValue)
return;
try {
s_eventBus = ComponentContext.getComponent(EventBus.class);
eventDistributor = ComponentContext.getComponent(EventDistributor.class);
} catch (NoSuchBeanDefinitionException nbe) {
return; // no provider is configured to provide events bus, so just return
return; // no provider is configured to provide events distributor, so just return
}

Account account = s_accountDao.findById(accountId);
Expand Down Expand Up @@ -238,11 +238,7 @@ private static void publishUsageEvent(String usageEventType, Long accountId, Lon

event.setDescription(eventDescription);

try {
s_eventBus.publish(event);
} catch (EventBusException e) {
LOGGER.warn("Failed to publish usage event on the event bus.");
}
eventDistributor.publish(event);
}

static final String Name = "management-server";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
import javax.inject.Inject;

import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.framework.events.EventBus;
import org.apache.cloudstack.framework.events.EventBusException;
import org.apache.logging.log4j.Logger;
import org.apache.cloudstack.framework.events.EventDistributor;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.apache.logging.log4j.Logger;

import com.cloud.event.EventCategory;
import com.cloud.network.Network.Event;
Expand All @@ -43,14 +41,18 @@ public class NetworkStateListener implements StateListener<State, Event, Network
@Inject
private ConfigurationDao _configDao;

private static EventBus s_eventBus = null;
private EventDistributor eventDistributor;

protected Logger logger = LogManager.getLogger(getClass());

public NetworkStateListener(ConfigurationDao configDao) {
_configDao = configDao;
}

public void setEventDistributor(EventDistributor eventDistributor) {
this.eventDistributor = eventDistributor;
}

@Override
public boolean preStateTransitionEvent(State oldState, Event event, State newState, Network vo, boolean status, Object opaque) {
pubishOnEventBus(event.name(), "preStateTransitionEvent", vo, oldState, newState);
Expand All @@ -66,23 +68,20 @@ public boolean postStateTransitionEvent(StateMachine2.Transition<State, Event> t
return true;
}

private void pubishOnEventBus(String event, String status, Network vo, State oldState, State newState) {

private void pubishOnEventBus(String event, String status, Network vo, State oldState, State newState) {
String configKey = "publish.resource.state.events";
String value = _configDao.getValue(configKey);
boolean configValue = Boolean.parseBoolean(value);
if(!configValue)
return;
try {
s_eventBus = ComponentContext.getComponent(EventBus.class);
} catch (NoSuchBeanDefinitionException nbe) {
return; // no provider is configured to provide events bus, so just return
if (eventDistributor == null) {
setEventDistributor(ComponentContext.getComponent(EventDistributor.class));
}

String resourceName = getEntityFromClassName(Network.class.getName());
org.apache.cloudstack.framework.events.Event eventMsg =
new org.apache.cloudstack.framework.events.Event("management-server", EventCategory.RESOURCE_STATE_CHANGE_EVENT.getName(), event, resourceName, vo.getUuid());
Map<String, String> eventDescription = new HashMap<String, String>();
new org.apache.cloudstack.framework.events.Event("management-server", EventCategory.RESOURCE_STATE_CHANGE_EVENT.getName(), event, resourceName, vo.getUuid());
Map<String, String> eventDescription = new HashMap<>();
eventDescription.put("resource", resourceName);
eventDescription.put("id", vo.getUuid());
eventDescription.put("old-state", oldState.name());
Expand All @@ -92,11 +91,8 @@ private void pubishOnEventBus(String event, String status, Network vo, State old
eventDescription.put("eventDateTime", eventDate);

eventMsg.setDescription(eventDescription);
try {
s_eventBus.publish(eventMsg);
} catch (EventBusException e) {
logger.warn("Failed to publish state change event on the event bus.");
}

eventDistributor.publish(eventMsg);
}

private String getEntityFromClassName(String entityClassName) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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.
package com.cloud.network;

import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.framework.events.EventDistributor;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mockito;
import org.springframework.test.util.ReflectionTestUtils;

public class NetworkStateListenerTest {
@InjectMocks
NetworkStateListener networkStateListener = new NetworkStateListener(Mockito.mock(ConfigurationDao.class));

@Test
public void testSetEventDistributor() {
EventDistributor eventDistributor = null;
networkStateListener.setEventDistributor(eventDistributor);
Assert.assertNull(ReflectionTestUtils.getField(networkStateListener, "eventDistributor"));
eventDistributor = Mockito.mock(EventDistributor.class);
networkStateListener.setEventDistributor(eventDistributor);
Assert.assertEquals(eventDistributor, ReflectionTestUtils.getField(networkStateListener, "eventDistributor"));
}
}
Loading