private static ConfigurationSyncResponse convert(ConfigurationServerSync source) { if (source == null) { return null; } ConfigurationSyncResponse sync = new ConfigurationSyncResponse(); sync.setConfDeltaBody(source.getConfDeltaBody()); sync.setConfSchemaBody(source.getConfSchemaBody()); sync.setResponseStatus(convert(source.getResponseStatus())); return sync; }
@Test public void testOnConfigurationResponse() throws Exception { KaaClientState clientState = Mockito.mock(KaaClientState.class); SchemaProcessor schemaProcessor = Mockito.mock(SchemaProcessor.class); ConfigurationProcessor configProcessor = Mockito.mock(ConfigurationProcessor.class); ConfigurationSyncResponse response = new ConfigurationSyncResponse(); response.setResponseStatus(SyncResponseStatus.DELTA); KaaChannelManager channelManagerMock = Mockito.mock(KaaChannelManager.class); ConfigurationTransport transport = new DefaultConfigurationTransport(); transport.setChannelManager(channelManagerMock); transport.onConfigurationResponse(response); transport.setClientState(clientState); transport.onConfigurationResponse(response); transport.setConfigurationProcessor(configProcessor); transport.onConfigurationResponse(response); transport.setSchemaProcessor(schemaProcessor); transport.onConfigurationResponse(response); response.setConfDeltaBody(ByteBuffer.wrap(new byte[]{1, 2, 3})); transport.onConfigurationResponse(response); response.setConfSchemaBody(ByteBuffer.wrap(new byte[]{1, 2, 3})); transport.onConfigurationResponse(response); Mockito.verify(schemaProcessor, Mockito.times(1)).loadSchema(Mockito.eq(ByteBuffer.wrap(new byte[]{1, 2, 3}))); Mockito.verify(configProcessor, Mockito.times(2)).processConfigurationData(Mockito.eq(ByteBuffer.wrap(new byte[]{1, 2, 3})), Mockito.eq(false)); }