Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <[email protected]>
  • Loading branch information
cdjackson committed Oct 5, 2024
1 parent fc5ea82 commit 9c30677
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,10 @@ public ZigBeeStatus initialize() {
if (networkParametersResponse == null) {
return ZigBeeStatus.COMMUNICATION_ERROR;
}
networkParameters = networkParametersResponse.getParameters();
EmberNetworkParameters localNetworkParameters = networkParametersResponse.getParameters();
if (localNetworkParameters != null) {
networkParameters = localNetworkParameters;
}
logger.debug("Ember initial network parameters are {}", networkParameters);

ieeeAddress = ncp.getIeeeAddress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.zsmartsystems.zigbee.TestUtilities;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.command.EzspGetNetworkParametersResponse;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.command.EzspGetParentChildParametersResponse;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.command.EzspVersionResponse;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.structure.EmberCurrentSecurityState;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.structure.EmberNetworkParameters;
import com.zsmartsystems.zigbee.dongle.ember.ezsp.structure.EmberNetworkStatus;
Expand All @@ -24,6 +25,7 @@
import com.zsmartsystems.zigbee.dongle.ember.ezsp.structure.EzspStatus;
import com.zsmartsystems.zigbee.dongle.ember.internal.EzspProtocolHandler;
import com.zsmartsystems.zigbee.transport.ZigBeePort;
import com.zsmartsystems.zigbee.transport.ZigBeeTransportReceive;
import com.zsmartsystems.zigbee.transport.ZigBeeTransportTransmitAbstractTest;

/**
Expand Down Expand Up @@ -52,6 +54,11 @@ public void initialiseTransport() throws Exception {
Mockito.when(ncp.setRadioPower(ArgumentMatchers.anyInt())).thenReturn(EmberStatus.EMBER_SUCCESS);
Mockito.when(ncp.getNwkAddress()).thenReturn(Integer.valueOf(0));
Mockito.when(ncp.getIeeeAddress()).thenReturn(new IeeeAddress("1234567890ABCDEF"));
final EzspVersionResponse version = Mockito.mock(EzspVersionResponse.class);
Mockito.when(version.getProtocolVersion()).thenReturn(4);

Mockito.when(ncp.getVersion()).thenReturn(version);
Mockito.when(ncp.getNetworkParameters()).thenReturn(Mockito.mock(EzspGetNetworkParametersResponse.class));

ZigBeePort port = Mockito.mock(ZigBeePort.class);
Mockito.when(port.open()).thenReturn(Boolean.TRUE);
Expand All @@ -62,8 +69,13 @@ public EmberNcp getEmberNcp() {
return ncp;
}
};
EzspProtocolHandler frameHandler = Mockito.mock(EzspProtocolHandler.class);
Mockito.when(frameHandler.isAlive()).thenReturn(Boolean.TRUE);
TestUtilities.setField(ZigBeeDongleEzsp.class, dongle, "frameHandler", frameHandler);

final ZigBeeTransportReceive receiver = Mockito.mock(ZigBeeTransportReceive.class);

TestUtilities.setField(ZigBeeDongleEzsp.class, dongle, "frameHandler", Mockito.mock(EzspProtocolHandler.class));
dongle.setZigBeeTransportReceive(receiver);

transport = dongle;
}
Expand Down

0 comments on commit 9c30677

Please sign in to comment.