@Inject public ResponseInfoXPathSet(AdsApiConfiguration apiConfig, NodeExtractor nodeExtractor) { this.requestIdXPath = new IterableXPath(apiConfig.getRequestIdXPath()); this.responseTimeXPath = new IterableXPath(apiConfig.getResponseTimeXPath()); this.operationsCountXPath = new IterableXPath(apiConfig.getResponseOperationsCountXPath()); this.nodeExtractor = nodeExtractor; }
@Test public void testValidXPathWithTrailingSlash() { String xPath = "/Envelope/RequestHeader/SomeValue/"; IterableXPath iterableXPath = new IterableXPath(xPath); assertEquals(xPath, iterableXPath.getXPath()); String[] expected = new String[] {"Envelope", "RequestHeader", "SomeValue"}; assertArrayEquals(expected, Iterables.toArray(iterableXPath, String.class)); }
@Test public void testGettersWithNullConfigXPaths() { apiConfig = Mockito.mock(AdsApiConfiguration.class); xPathSet = new ResponseInfoXPathSet(apiConfig, nodeExtractor); assertFalse( "getOperationsXPath should have returned an empty iterator", xPathSet.getOperationsCountXPath().iterator().hasNext()); }
@Test public void testEmptyXPath() { String xPath = ""; IterableXPath iterableXPath = new IterableXPath(xPath); assertEquals(xPath, iterableXPath.getXPath()); assertArrayEquals(new String[0], Iterables.toArray(iterableXPath, String.class)); }
@Test public void testGettersWithNullConfigXPaths() { when(apiConfig.getRequestContextXPath()).thenReturn(null); xPathSet = new RequestInfoXPathSet(apiConfig, nodeExtractor, transformerSupplier, logger); assertNull( "getContextName should have returned null when no context XPath was supplied", xPathSet.getContextName()); assertFalse( "getContextXPath should have returned an empty iterator when no context XPath was supplied", xPathSet.getContextXPath().iterator().hasNext()); }
@Test public void testNullXPath() { String xPath = null; IterableXPath iterableXPath = new IterableXPath(xPath); assertEquals(xPath, iterableXPath.getXPath()); assertArrayEquals(new String[0], Iterables.toArray(iterableXPath, String.class)); } }
@Inject public ResponseInfoXPathSet(AdsApiConfiguration apiConfig, NodeExtractor nodeExtractor) { this.requestIdXPath = new IterableXPath(apiConfig.getRequestIdXPath()); this.responseTimeXPath = new IterableXPath(apiConfig.getResponseTimeXPath()); this.operationsCountXPath = new IterableXPath(apiConfig.getResponseOperationsCountXPath()); this.nodeExtractor = nodeExtractor; }
@Test public void testValidXPathWithoutLeadingSlash() { String xPath = "Envelope/RequestHeader/SomeValue"; IterableXPath iterableXPath = new IterableXPath(xPath); assertEquals(xPath, iterableXPath.getXPath()); String[] expected = new String[] {"Envelope", "RequestHeader", "SomeValue"}; assertArrayEquals(expected, Iterables.toArray(iterableXPath, String.class)); }
@Inject public RequestInfoXPathSet( AdsApiConfiguration apiConfig, NodeExtractor nodeExtractor, Supplier<Transformer> transformerSupplier, @Named("libLogger") Logger libLogger) { Preconditions.checkNotNull(apiConfig); this.contextXPath = new IterableXPath(apiConfig.getRequestContextXPath()); this.contextName = Iterables.isEmpty(this.contextXPath) ? null : Iterables.getLast(this.contextXPath); this.nodeExtractor = Preconditions.checkNotNull(nodeExtractor); this.transformerSupplier = Preconditions.checkNotNull(transformerSupplier); this.libLogger = Preconditions.checkNotNull(libLogger); }
@Test public void testValidXPathWithLeadingSlash() { String xPath = "/Envelope/RequestHeader/SomeValue"; IterableXPath iterableXPath = new IterableXPath(xPath); assertEquals(xPath, iterableXPath.getXPath()); String[] expected = new String[] {"Envelope", "RequestHeader", "SomeValue"}; assertArrayEquals(expected, Iterables.toArray(iterableXPath, String.class)); }
@Inject public RequestInfoXPathSet( AdsApiConfiguration apiConfig, NodeExtractor nodeExtractor, Supplier<Transformer> transformerSupplier, @Named("libLogger") Logger libLogger) { Preconditions.checkNotNull(apiConfig); this.contextXPath = new IterableXPath(apiConfig.getRequestContextXPath()); this.contextName = Iterables.isEmpty(this.contextXPath) ? null : Iterables.getLast(this.contextXPath); this.nodeExtractor = Preconditions.checkNotNull(nodeExtractor); this.transformerSupplier = Preconditions.checkNotNull(transformerSupplier); this.libLogger = Preconditions.checkNotNull(libLogger); }