PduV2Factory implements PduFactory { public ExtenderConfiguration readExtenderConfigurationResponse(ServiceCredentials credentials, TLVElement input) throws KSIException { return this.extenderPduV2Factory.readExtenderConfigurationResponse(credentials, input); } PduV2Factory();  PduV2Factory(AggregatorPduV2Factory aggregatorPduV2Factory, ExtenderPduV2Factory extenderPduV2Factory);  PduV2Factory(AggregatorPduV2Factory aggregatorPduV2Factory);  PduV2Factory(ExtenderPduV2Factory extenderPduV2Factory); AggregationRequest createAggregationRequest(KSIRequestContext context, ServiceCredentials credentials, DataHash imprint, Long level); AggregationResponse readAggregationResponse(KSIRequestContext context, ServiceCredentials credentials, TLVElement input); AggregationRequest createAggregatorConfigurationRequest(KSIRequestContext context, ServiceCredentials credentials); AggregatorConfiguration readAggregatorConfigurationResponse(KSIRequestContext context, ServiceCredentials credentials, TLVElement input); ExtensionRequest createExtensionRequest(KSIRequestContext context, ServiceCredentials credentials, Date aggregationTime, Date publicationTime); ExtensionResponse readExtensionResponse(KSIRequestContext context, ServiceCredentials credentials, TLVElement input); ExtensionRequest createExtensionConfigurationRequest(KSIRequestContext context, ServiceCredentials credentials); ExtenderConfiguration readExtenderConfigurationResponse(ServiceCredentials credentials, TLVElement input);  }
@Test public void testExtenderConfigurationResponseParsingWithMultiplePayloadsV2() throws Exception { ExtenderConfiguration cnf = pduFactory.readExtenderConfigurationResponse(CREDENTIALS, loadTlv("pdu/extension/extender-response-with-conf-and-calendar.tlv")); Assert.assertTrue(cnf.getCalendarFirstTime().equals(new Date(5557150000L))); Assert.assertTrue(cnf.getCalendarLastTime().equals(new Date(1422630579000L))); Assert.assertTrue(cnf.getMaximumRequests().equals(4L)); Assert.assertTrue(cnf.getParents().size() == 3); for (String parent : cnf.getParents()){ Assert.assertTrue(parent.contains(".url")); } }
@Test public void testExtenderResponseParsingWithMultipleConfsV2() throws Exception { ExtenderConfiguration cnf = pduFactory.readExtenderConfigurationResponse(CREDENTIALS, loadTlv("pdu/extension/extender-response-multiple-confs.tlv")); Assert.assertNotNull(cnf); Assert.assertTrue(cnf.getCalendarFirstTime().equals(new Date(158000))); Assert.assertTrue(cnf.getCalendarLastTime().equals(new Date(40627000))); Assert.assertTrue(cnf.getMaximumRequests().equals(2L)); Assert.assertTrue(cnf.getParents().size() == 1); for (String parent : cnf.getParents()){ Assert.assertEquals(parent, "anon"); } }
@Test public void testExtenderResponseParsingWithEmptyConfV2() throws Exception { ExtenderConfiguration cnf = pduFactory.readExtenderConfigurationResponse(CREDENTIALS, loadTlv("pdu/extension/extender-response-with-empty-conf.tlv")); Assert.assertNotNull(cnf); Assert.assertNull(cnf.getCalendarFirstTime()); Assert.assertNull(cnf.getCalendarLastTime()); Assert.assertNull(cnf.getMaximumRequests()); Assert.assertTrue(cnf.getParents().isEmpty()); }
@Test(expectedExceptions = KSIProtocolException.class, expectedExceptionsMessageRegExp = "Received unknown response to PDU v2 extension request.") public void testReadV1ExtensionConfigurationResponse() throws Exception { pduFactory.readExtenderConfigurationResponse(CREDENTIALS, loadTlv("pdu/extension/extension-response-v1-ok-request-id-4321.tlv")); }
@Test public void testReadExtenderConfigurationResponse() throws Exception { ExtenderConfiguration response = pduFactory.readExtenderConfigurationResponse(CREDENTIALS, loadTlv("pdu/extension/extender-conf-response-ok.tlv")); Assert.assertNotNull(response); Assert.assertNotNull(response.getCalendarFirstTime()); Assert.assertNotNull(response.getCalendarLastTime()); Assert.assertNotNull(response.getParents()); Assert.assertEquals(response.getParents().size(), 3); Assert.assertEquals(response.getMaximumRequests(), Long.valueOf(4)); }