src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
DhcpRelayValidator implements Validator<Relay> { @VisibleForTesting void validateRelay(final Relay relay) { final boolean isIpv6 = Ipv6.class == relay.getAddressFamily(); try { isAddressCorrect(relay.getGatewayAddress(), isIpv6); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(String.format("G... | @Test(expected = IllegalArgumentException.class) public void testMixedIpAddressFamilies( @InjectTestData(resourcePath = "/relay/ipv4DhcpRelay.json", id = RELAYS_PATH) Relays relays) { RelayBuilder builder = new RelayBuilder(); builder.fieldsFrom(extractRelay(relays)); builder.setGatewayAddress(IpAddressNoZoneBuilder.ge... |
DhcpRelayCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Relay, RelayKey>,
JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator { @Override public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Relay> id, @Nonnull final Relay dataAfter, @Nonnull final WriteCon... | @Test public void testWrite(@InjectTestData(resourcePath = "/relay/ipv4DhcpRelay.json", id = RELAYS_PATH) Relays relays) throws WriteFailedException { final Relay data = relays.getRelay().get(0); final int rxVrfId = 0; customizer.writeCurrentAttributes(getId(rxVrfId, Ipv4.class), data, writeContext); final DhcpProxyCon... |
DhcpRelayCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Relay, RelayKey>,
JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator { @Override public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Relay> id, @Nonnull final Relay dataBefore, @Nonnull final Relay ... | @Test public void testUpdate( @InjectTestData(resourcePath = "/relay/ipv6DhcpRelayBefore.json", id = RELAYS_PATH) Relays relaysBefore, @InjectTestData(resourcePath = "/relay/ipv6DhcpRelayAfter.json", id = RELAYS_PATH) Relays relayAfter) throws WriteFailedException { final Relay before = relaysBefore.getRelay().get(0); ... |
DhcpRelayCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Relay, RelayKey>,
JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator { @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Relay> id, @Nonnull final Relay dataBefore, @Nonnull final WriteC... | @Test public void testDelete(@InjectTestData(resourcePath = "/relay/ipv4DhcpRelay.json", id = RELAYS_PATH) Relays relays) throws WriteFailedException { final Relay data = relays.getRelay().get(0); final int rxVrfId = 0; customizer.deleteCurrentAttributes(getId(rxVrfId, Ipv4.class), data, writeContext); final DhcpProxyC... |
DhcpRelayCustomizer extends FutureJVppCustomizer implements InitializingListReaderCustomizer<Relay, RelayKey, RelayBuilder>,
JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator { @Nonnull @Override public List<RelayKey> getAllIds(@Nonnull final InstanceIdentifier<Relay> id, @Nonnull final ReadCont... | @Test public void testGetAllIds() throws ReadFailedException { final List<RelayKey> allIds = getCustomizer().getAllIds(RELAYS.child(Relay.class), ctx); assertEquals(2, allIds.size()); assertThat(allIds, containsInAnyOrder(IP4_IID.getKey(), IP6_IID.getKey())); } |
DhcpRelayCustomizer extends FutureJVppCustomizer implements InitializingListReaderCustomizer<Relay, RelayKey, RelayBuilder>,
JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator { @Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Relay> id, @Nonnull final RelayBuilder bu... | @Test public void testReadIp4() throws ReadFailedException { final RelayBuilder builder = new RelayBuilder(); getCustomizer().readCurrentAttributes(IP4_IID, builder, ctx); assertEquals(IP4_IID.getKey().getAddressFamily(), builder.getAddressFamily()); assertEquals(IP4_IID.getKey().getRxVrfId(), builder.getRxVrfId()); as... |
DhcpRelayCustomizer extends FutureJVppCustomizer implements InitializingListReaderCustomizer<Relay, RelayKey, RelayBuilder>,
JvppReplyConsumer, ByteDataTranslator, Ipv6Translator, Ipv4Translator { @Nonnull @Override public Initialized<? extends DataObject> init(@Nonnull final InstanceIdentifier<Relay> id, @Nonnull ... | @Test public void testInit() { final Relay data = new RelayBuilder().build(); invokeInitTest(IP4_IID, data, IP4_IID, data); } |
AclValidator implements Validator<Acl>, AclDataExtractor { @Override public void validateUpdate(final InstanceIdentifier<Acl> id, final Acl dataBefore, final Acl dataAfter, final WriteContext ctx) throws UpdateValidationFailedException { try { validateAcl(dataAfter); } catch (RuntimeException e) { throw new UpdateValid... | @Test public void testValidateUpdate( @InjectTestData(resourcePath = "/acl/standard/standard-acl-icmp.json") Acls acls) throws DataValidationFailedException.UpdateValidationFailedException { final Acl data = acls.getAcl().get(0); validator.validateUpdate(ID, data, data, writeContext); }
@Test(expected = DataValidationF... |
BgpPrefixSidMplsWriter implements RouteWriter<LabeledUnicastRoute>, MplsRouteRequestProducer, IpRouteRequestProducer, JvppReplyConsumer { @Override public void create(@Nonnull final InstanceIdentifier<LabeledUnicastRoute> id, @Nonnull final LabeledUnicastRoute route) throws WriteFailedException.CreateFailedException { ... | @Test public void testCreate() throws WriteFailedException.CreateFailedException { final String routeKey = "route-key"; final PathId pathId = new PathId(123L); writer.create(id(pathId, routeKey), route(pathId, routeKey)); verify(vppApi, times(2)).mplsRouteAddDel(any()); verify(vppApi, atLeastOnce()).mplsRouteAddDel(get... |
BgpPrefixSidMplsWriter implements RouteWriter<LabeledUnicastRoute>, MplsRouteRequestProducer, IpRouteRequestProducer, JvppReplyConsumer { @Override public void delete(@Nonnull final InstanceIdentifier<LabeledUnicastRoute> id, @Nonnull final LabeledUnicastRoute route) throws WriteFailedException.DeleteFailedException { ... | @Test public void testDelete() throws WriteFailedException.DeleteFailedException { final String routeKey = "route-key"; final PathId pathId = new PathId(123L); writer.delete(id(pathId, routeKey), route(pathId, routeKey)); verify(vppApi, times(2)).mplsRouteAddDel(any()); verify(vppApi, atLeastOnce()).mplsRouteAddDel(get... |
BgpPrefixSidMplsWriter implements RouteWriter<LabeledUnicastRoute>, MplsRouteRequestProducer, IpRouteRequestProducer, JvppReplyConsumer { @Override public void update(@Nonnull final InstanceIdentifier<LabeledUnicastRoute> id, @Nonnull final LabeledUnicastRoute routeBefore, @Nonnull final LabeledUnicastRoute routeAfter)... | @Test(expected = WriteFailedException.UpdateFailedException.class) public void testUpdate() throws WriteFailedException.UpdateFailedException { final String routeKey = "route-key"; final PathId pathId = new PathId(123L); writer.update(id(pathId, routeKey), mock(LabeledUnicastRoute.class), mock(LabeledUnicastRoute.class... |
Ipv4Writer implements RouteWriter<Ipv4Route>, Ipv4Translator, JvppReplyConsumer, RouteRequestProducer { @Override public void create(@Nonnull final InstanceIdentifier<Ipv4Route> id, @Nonnull final Ipv4Route route) throws WriteFailedException.CreateFailedException { final IpAddDelRoute request = request(route, true); LO... | @Test public void testCreate() throws WriteFailedException.CreateFailedException { final Ipv4Prefix destination = new Ipv4Prefix("1.2.3.4/24"); final PathId pathId = new PathId(123L); final Ipv4Address nextHopAddress = new Ipv4AddressNoZone("5.6.7.8"); writer.create( id(destination, pathId), route(destination, pathId, ... |
Ipv4Writer implements RouteWriter<Ipv4Route>, Ipv4Translator, JvppReplyConsumer, RouteRequestProducer { @Override public void delete(@Nonnull final InstanceIdentifier<Ipv4Route> id, @Nonnull final Ipv4Route route) throws WriteFailedException.DeleteFailedException { LOG.debug("Removing id={}, route={}", id, route); getR... | @Test public void testDelete() throws WriteFailedException.DeleteFailedException { final Ipv4Prefix destination = new Ipv4Prefix("1.2.3.4/24"); final PathId pathId = new PathId(456L); final Ipv4Address nextHopAddress = new Ipv4AddressNoZone("5.6.7.8"); writer.delete( id(destination, pathId), route(destination, pathId, ... |
Ipv4Writer implements RouteWriter<Ipv4Route>, Ipv4Translator, JvppReplyConsumer, RouteRequestProducer { @Override public void update(@Nonnull final InstanceIdentifier<Ipv4Route> id, @Nonnull final Ipv4Route routeBefore, @Nonnull final Ipv4Route routeAfter) throws WriteFailedException.UpdateFailedException { throw new W... | @Test(expected = WriteFailedException.UpdateFailedException.class) public void testUpdate() throws WriteFailedException.UpdateFailedException { final Ipv4Prefix destination = new Ipv4Prefix("10.1.0.1/28"); final PathId pathId = new PathId(456L); writer.update(id(destination, pathId), mock(Ipv4Route.class), mock(Ipv4Rou... |
Ipv6Writer implements RouteWriter<Ipv6Route>, Ipv6Translator, JvppReplyConsumer, RouteRequestProducer { @Override public void create(@Nonnull final InstanceIdentifier<Ipv6Route> id, @Nonnull final Ipv6Route route) throws WriteFailedException.CreateFailedException { final IpAddDelRoute request = request(route, true); LO... | @Test public void testCreate() throws WriteFailedException.CreateFailedException { final Ipv6Prefix destination = new Ipv6Prefix("2001:db8:a0b:12f0:0:0:0:1/64"); final PathId pathId = new PathId(123L); final Ipv6Address nextHopAddress = new Ipv6AddressNoZone("2001:db8:a0b:12f0:0:0:0:2"); writer.create( id(destination, ... |
Ipv6Writer implements RouteWriter<Ipv6Route>, Ipv6Translator, JvppReplyConsumer, RouteRequestProducer { @Override public void delete(@Nonnull final InstanceIdentifier<Ipv6Route> id, @Nonnull final Ipv6Route route) throws WriteFailedException.DeleteFailedException { LOG.debug("Removing id={}, route={}", id, route); getR... | @Test public void testDelete() throws WriteFailedException.DeleteFailedException { final Ipv6Prefix destination = new Ipv6Prefix("2001:db8:a0b:12f0:0:0:0:1/64"); final PathId pathId = new PathId(456L); final Ipv6Address nextHopAddress = new Ipv6AddressNoZone("2001:db8:a0b:12f0:0:0:0:2"); writer.delete( id(destination, ... |
Ipv6Writer implements RouteWriter<Ipv6Route>, Ipv6Translator, JvppReplyConsumer, RouteRequestProducer { @Override public void update(@Nonnull final InstanceIdentifier<Ipv6Route> id, @Nonnull final Ipv6Route routeBefore, @Nonnull final Ipv6Route routeAfter) throws WriteFailedException.UpdateFailedException { throw new W... | @Test(expected = WriteFailedException.UpdateFailedException.class) public void testUpdate() throws WriteFailedException.UpdateFailedException { final Ipv6Prefix destination = new Ipv6Prefix("2001:db8:a0b:12f0:0:0:0:1/64"); final PathId pathId = new PathId(456L); writer.update(id(destination, pathId), mock(Ipv6Route.cla... |
NshMapReaderCustomizer extends FutureJVppNshCustomizer implements InitializingListReaderCustomizer<NshMap, NshMapKey, NshMapBuilder>, JvppReplyConsumer { @Nonnull @Override public List<NshMapKey> getAllIds(@Nonnull final InstanceIdentifier<NshMap> id, @Nonnull final ReadContext context) throws ReadFailedException { LOG... | @Test public void testGetAllIds() throws ReadFailedException { final NshMapDetailsReplyDump reply = new NshMapDetailsReplyDump(); final NshMapDetails nshMapDetails_1 = new NshMapDetails(); nshMapDetails_1.mapIndex = MAP_INDEX_1; nshMapDetails_1.nspNsi = (184<<8 | 255); nshMapDetails_1.mappedNspNsi = (183<<8 | 254); nsh... |
AclValidator implements Validator<Acl>, AclDataExtractor { @Override public void validateDelete(final InstanceIdentifier<Acl> id, final Acl dataBefore, final WriteContext ctx) throws DeleteValidationFailedException { try { validateAcl(dataBefore); final List<String> references = checkAclReferenced(ctx, dataBefore); che... | @Test public void testValidateDelete( @InjectTestData(resourcePath = "/acl/standard/standard-acl-icmp.json") Acls acls) throws DataValidationFailedException.DeleteValidationFailedException { validator.validateDelete(ID, acls.getAcl().get(0), writeContext); }
@Test(expected = DataValidationFailedException.DeleteValidati... |
AclValidator implements Validator<Acl>, AclDataExtractor { @VisibleForTesting static List<String> checkAclReferenced(@Nonnull final WriteContext writeContext, @Nonnull final Acl acl) { Preconditions.checkNotNull(acl.getType(), "Cannot validate acl: {}, type is not set.", acl); if (!acl.getType().equals(VppAcl.class) &&... | @Test public void testReferencedVppAclFirst() { final List<String> referenced = checkAclReferenced(writeContext, new AclBuilder() .setName("acl1").setType(VppAcl.class).build()); assertThat(referenced, hasSize(3)); assertThat(new HashSet<>(referenced), containsInAnyOrder("eth0", "eth1", "eth2")); }
@Test public void te... |
EgressAclCustomizer extends AbstractAclCustomizer implements InitializingListReaderCustomizer<AclSet, AclSetKey, AclSetBuilder>, JvppReplyConsumer { @Nonnull @Override public List<AclSetKey> getAllIds(@Nonnull final InstanceIdentifier<AclSet> instanceIdentifier, @Nonnull final ReadContext readContext) throws ReadFailed... | @Test public void testGetAllIdsNoOutputAclConfigured() throws ReadFailedException { final AclInterfaceListDetailsReplyDump reply = aclInterfaceDump((byte) 1, "acl1"); when(aclApi.aclInterfaceListDump(any())).thenReturn(future(reply)); assertTrue(getCustomizer().getAllIds(getWildcardedIid(IF_NAME), ctx).isEmpty()); }
@T... |
AclCustomizer extends FutureJVppAclCustomizer implements InitializingListReaderCustomizer<Acl, AclKey, AclBuilder>, JvppReplyConsumer, Ipv6Translator,
Ipv4Translator, IpProtocolReader, AceConverter { @Nonnull @Override public List<AclKey> getAllIds(@Nonnull final InstanceIdentifier<Acl> id, @Nonnull final ReadConte... | @Test public void testGetAllIds() throws ReadFailedException { final List<AclKey> allIds = getCustomizer().getAllIds(InstanceIdentifier.create(Acls.class).child(Acl.class), ctx); assertEquals(2, allIds.size()); assertEquals(ACL_IID.getKey(), allIds.get(0)); assertEquals(MACIP_ACL_IID.getKey(), allIds.get(1)); } |
AclCustomizer extends FutureJVppAclCustomizer implements InitializingListReaderCustomizer<Acl, AclKey, AclBuilder>, JvppReplyConsumer, Ipv6Translator,
Ipv4Translator, IpProtocolReader, AceConverter { @Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier<Acl> id, @Nonnull final AclBuilder bui... | @Test public void testReadStandardAcl() throws ReadFailedException { final AclBuilder builder = new AclBuilder(); getCustomizer().readCurrentAttributes(ACL_IID, builder, ctx); assertEquals(ACL_IID.getKey(), builder.key()); final List<Ace> aces = builder.getAces().getAce(); assertEquals(1, aces.size()); final Ace ace = ... |
NshEntryReaderCustomizer extends FutureJVppNshCustomizer implements InitializingListReaderCustomizer<NshEntry, NshEntryKey, NshEntryBuilder>, JvppReplyConsumer { @Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier<NshEntry> id, @Nonnull final NshEntryBuilder builder, @Nonnull final ReadContext... | @Test public void testreadCurrentAttributes() throws ReadFailedException { NshEntryBuilder builder = new NshEntryBuilder(); getCustomizer().readCurrentAttributes(getNshEntryId(ENTRY_NAME_1), builder, ctx); assertEquals(0, builder.getVersion().intValue()); assertEquals(6, builder.getLength().intValue()); assertEquals(Md... |
IngressAclCustomizer extends AbstractAclCustomizer implements InitializingListReaderCustomizer<AclSet, AclSetKey, AclSetBuilder>, JvppReplyConsumer { @Nonnull @Override public List<AclSetKey> getAllIds(@Nonnull final InstanceIdentifier<AclSet> instanceIdentifier, @Nonnull final ReadContext readContext) throws ReadFaile... | @Test public void testGetAllIdsNoInputAclConfigured() throws ReadFailedException { final AclInterfaceListDetailsReplyDump reply = aclInterfaceDump((byte) 0, "acl1"); when(aclApi.aclInterfaceListDump(aclInterfaceRequest(IF_ID))).thenReturn(future(reply)); assertTrue(getCustomizer().getAllIds(getWildcardedIid(IF_NAME), c... |
IoamPotWriterCustomizer extends FutureJVppIoampotCustomizer implements
ListWriterCustomizer<PotProfileSet,PotProfileSetKey>, JvppReplyConsumer { @Override public void writeCurrentAttributes(@Nonnull InstanceIdentifier<PotProfileSet> id, @Nonnull PotProfileSet dataAfter, @Nonnull WriteContext writeContext) throw... | @Test public void testCreate() throws Exception { final PotProfileSet potProfileSet = generatePotProfileSet(); final InstanceIdentifier<PotProfileSet> id = getPotProfileSetId(POT_TEST_NAME); whenPotAddThenSuccess(); customizer.writeCurrentAttributes(id, potProfileSet, writeContext); verify(jVppIoamPot).potProfileAdd(ge... |
IoamPotWriterCustomizer extends FutureJVppIoampotCustomizer implements
ListWriterCustomizer<PotProfileSet,PotProfileSetKey>, JvppReplyConsumer { @Override public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<PotProfileSet> id, @Nonnull PotProfileSet dataBefore, @Nonnull WriteContext writeContext) thr... | @Test public void testDelete() throws Exception { final PotProfileSet potProfileSet = generatePotProfileSet(); final InstanceIdentifier<PotProfileSet> id = getPotProfileSetId(POT_TEST_NAME); whenPotDelThenSuccess(); customizer.deleteCurrentAttributes(id, potProfileSet, writeContext); verify(jVppIoamPot).potProfileDel(g... |
IoamExportWriterCustomizer extends FutureJVppIoamexportCustomizer implements WriterCustomizer<IoamExport>, JvppReplyConsumer, Ipv4Translator { @Override public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<IoamExport> instanceIdentifier, @Nonnull final IoamExport ioamExport, @Nonnull final WriteContext ... | @Test public void testCreate() throws Exception { final IoamExport ioamExport = generateExportProfile(); final InstanceIdentifier<IoamExport> id = InstanceIdentifier.create(IoamExport.class); whenExportAddThenSuccess(); customizer.writeCurrentAttributes(id, ioamExport, writeContext); verify(jVppIoamexport).ioamExportIp... |
IoamExportWriterCustomizer extends FutureJVppIoamexportCustomizer implements WriterCustomizer<IoamExport>, JvppReplyConsumer, Ipv4Translator { @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<IoamExport> instanceIdentifier, @Nonnull final IoamExport ioamExport, @Nonnull final WriteContext... | @Test public void testDelete() throws Exception { final IoamExport ioamExport = generateExportProfile(); final InstanceIdentifier<IoamExport> id = InstanceIdentifier.create(IoamExport.class); whenExportDelThenSuccess(); customizer.deleteCurrentAttributes(id, ioamExport, writeContext); verify(jVppIoamexport).ioamExportI... |
NshEntryReaderCustomizer extends FutureJVppNshCustomizer implements InitializingListReaderCustomizer<NshEntry, NshEntryKey, NshEntryBuilder>, JvppReplyConsumer { @Nonnull @Override public List<NshEntryKey> getAllIds(@Nonnull final InstanceIdentifier<NshEntry> id, @Nonnull final ReadContext context) throws ReadFailedExc... | @Test public void testGetAllIds() throws ReadFailedException { final NshEntryDetailsReplyDump reply = new NshEntryDetailsReplyDump(); final NshEntryDetails nshEntryDetails_1 = new NshEntryDetails(); nshEntryDetails_1.entryIndex = ENTRY_INDEX_1; nshEntryDetails_1.verOC = 0; nshEntryDetails_1.length = 6; nshEntryDetails_... |
IoamTraceWriterCustomizer extends FutureJVppIoamtraceCustomizer implements ListWriterCustomizer<TraceConfig, TraceConfigKey>, ByteDataTranslator, JvppReplyConsumer { @Override public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<TraceConfig> id, @Nonnull final TraceConfig dataCurr, @Nonnull final WriteC... | @Test public void testCreate() throws Exception { final TraceConfig traceConfig = generateTraceConfig(TRACE_NAME); final InstanceIdentifier<TraceConfig> id = getTraceConfigId(TRACE_NAME); whenTraceAddThenSuccess(); customizer.writeCurrentAttributes(id, traceConfig, writeContext); verify(jvppIoamtrace).traceProfileAdd(g... |
IoamTraceWriterCustomizer extends FutureJVppIoamtraceCustomizer implements ListWriterCustomizer<TraceConfig, TraceConfigKey>, ByteDataTranslator, JvppReplyConsumer { @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<TraceConfig> id, @Nonnull final TraceConfig dataBefore, @Nonnull final Wri... | @Test public void testDelete() throws Exception { final TraceConfig traceConfig = generateTraceConfig(TRACE_NAME); final InstanceIdentifier<TraceConfig> id = getTraceConfigId(TRACE_NAME); whenTraceDelThenSuccess(); customizer.deleteCurrentAttributes(id, traceConfig, writeContext); verify(jvppIoamtrace).traceProfileDel(... |
TraceProfileReaderCustomizer extends FutureJVppIoamtraceCustomizer implements InitializingListReaderCustomizer<TraceConfig, TraceConfigKey, TraceConfigBuilder>, JvppReplyConsumer { @Override public void readCurrentAttributes(@Nonnull InstanceIdentifier<TraceConfig> id, @Nonnull TraceConfigBuilder builder, @Nonnull Read... | @Test public void testReadCurrentAttributes() throws ReadFailedException { TraceConfigBuilder builder = new TraceConfigBuilder(); getCustomizer().readCurrentAttributes(InstanceIdentifier.create(IoamTraceConfig.class) .child(TraceConfig.class, new TraceConfigKey("Trace config")), builder, ctx); assertEquals(1234,builder... |
PotProfileReaderCustomizer extends FutureJVppIoampotCustomizer implements JvppReplyConsumer,
InitializingListReaderCustomizer<PotProfileList,PotProfileListKey,PotProfileListBuilder> { @Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier<PotProfileList> instanceIdentifier, @Nonnull final... | @Test public void testReadCurrentAttributes() throws ReadFailedException { PotProfileListBuilder builder = new PotProfileListBuilder(); getCustomizer().readCurrentAttributes(getPotProfileListId(0),builder,ctx); assertEquals(0x4,builder.getNumberOfBits().longValue()); assertEquals(0,builder.getIndex().getValue().intValu... |
Srv6Util { public static String getCandidatePathName(final Ipv6Address bsid, final long weight) { return bsid.getValue() + "-" + weight; } private Srv6Util(); static String getCandidatePathName(final Ipv6Address bsid, final long weight); static Ipv6Address extractBsid(
final @Nonnull InstanceIdentifier<T> ... | @Test public void getCandidatePathNameTest() { Assert.assertEquals(CANDIDATE_PATH_NAME, Srv6Util.getCandidatePathName(BSID, 0L)); } |
Srv6Util { public static <T extends DataObject> Ipv6Address extractBsid( final @Nonnull InstanceIdentifier<T> instanceIdentifier, final @Nonnull WriteContext writeContext, boolean isWrite) { Optional<Policy> policyOptional = isWrite ? writeContext.readAfter(RWUtils.cutId(instanceIdentifier, Policy.class)) : writeContex... | @Test public void extractBsidTest() { Assert.assertEquals(BSID.getValue(), Srv6Util.extractBsid(POLICY_IID, ctx, true).getValue()); } |
Srv6Util { public static <T extends DataObject> int extractVrfFib(final @Nonnull InstanceIdentifier<T> instanceIdentifier, final @Nonnull WriteContext writeContext, boolean isWrite) { Optional<Policy> policyOptional = isWrite ? writeContext.readAfter(RWUtils.cutId(instanceIdentifier, Policy.class)) : writeContext.readB... | @Test public void extractVrfFibTest() { Assert.assertEquals(0, Srv6Util.extractVrfFib(POLICY_IID, ctx, true)); } |
PrefixCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Prefix, PrefixKey>, JvppReplyConsumer, ByteDataTranslator, Ipv6Translator { @Override public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Prefix> id, @Nonnull final Prefix dataAfter, @Nonnull final WriteContext writeContext) ... | @Test public void testWriteSimple(@InjectTestData(resourcePath = "/ra/simplePrefix.json", id = RA_PATH) PrefixList prefixList) throws WriteFailedException, InterruptedException { final Prefix data = getPrefix(prefixList); customizer.writeCurrentAttributes(IID, data, writeContext); final SwInterfaceIp6NdRaPrefix request... |
PrettyPrinter { public static String toString(Node n) { return toString(n, null); } static String toString(Node n); static String toString(Node n, PrefixMapping prefixes); static String toString(Statement s); static String toString(Triple t); static String toString(Triple t, PrefixMapping prefixes); static String toSt... | @Test public void testNodePrettyPrinting() { Assert.assertEquals("\"foo\"", PrettyPrinter.toString(NodeFactory.createLiteral("foo"))); Assert.assertEquals("\"foo\"@en", PrettyPrinter.toString(NodeFactory.createLiteral("foo", "en", null))); Assert.assertEquals("\"1\"^^" + PrettyPrinter.LIBRARY.shortForm(XSDDatatype.XSDi... |
FilterParser { public Filter parseTableFilter(boolean matchParents) throws ParseException { List<Filter> result = new ArrayList<>(); for (List<IdentifierMatcher> list : parse()) { if (list.size() < 1 || list.size() > 2) { throw new ParseException("Syntax error in table filter list; expected list of comma- or newline-se... | @Test public void testParseAsTableFilter() throws ParseException { Filter result = new FilterParser("schema.table1,schema.table2,table3").parseTableFilter(false); Assert.assertTrue(result.matchesTable("schema", "table1")); Assert.assertTrue(result.matchesTable("schema", "table2")); Assert.assertTrue(result.matchesTable... |
FilterParser { public Filter parseColumnFilter(boolean matchParents) throws ParseException { List<Filter> result = new ArrayList<>(); for (List<IdentifierMatcher> list : parse()) { if (list.size() < 2 || list.size() > 3) { throw new ParseException("Syntax error in column filter list; expected list of comma- or newline-... | @Test public void testParseAsColumnFilter() throws ParseException { Filter result = new FilterParser("s.t1.c1,t2.c2,t2.c3").parseColumnFilter(false); Assert.assertTrue(result.matchesColumn("s", "t1", "c1")); Assert.assertTrue(result.matchesColumn(null, "t2", "c2")); Assert.assertTrue(result.matchesColumn(null, "t2", "c... |
IRIEncoder { public static String encode(String s) { StringBuilder sbuffer = new StringBuilder(s.length()); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); int cCode = (int) c; if (c == '-' || c == '_' || c == '~' || c == '.' || isDigit(cCode) || isLetter(cCode) || cCode >= 0x00A0) { sbuffer.append(c); } e... | @Test public void testDontEncodeAlphanumeric() { Assert.assertEquals("azAZ09", IRIEncoder.encode("azAZ09")); }
@Test public void testDontEncodeSafePunctuation() { Assert.assertEquals("-_.~", IRIEncoder.encode("-_.~")); }
@Test public void testDontEncodeUnicodeChars() { Assert.assertEquals("\u00E4", IRIEncoder.encode("\... |
TranslationTableParser { public Collection<Row> parseTranslations() { try { List<Row> result = new ArrayList<>(); while (true) { String line = this.reader.readLine(); if (line == null) { break; } String[] fields = this.csvLineParser.parse(line); if (fields.length != 2) { LOGGER.warn("Skipping line with {} instead of 2 ... | @Test public void testSimple() { String csv = "key,value"; Collection<TranslationTableParser.Row> translations = new TranslationTableParser(new StringReader(csv)).parseTranslations(); Assert.assertEquals(1, translations.size()); TranslationTableParser.Row t = translations.iterator().next(); Assert.assertEquals("key", t... |
GraphPatternTranslator { public List<NodeRelation> translate() { if (triplePatterns.isEmpty()) { return Collections.singletonList(NodeRelation.TRUE); } Iterator<Triple> it = triplePatterns.iterator(); List<CandidateList> candidateLists = new ArrayList<>(triplePatterns.size()); int index = 1; while (it.hasNext()) { Trip... | @Test public void testReturnMultipleMatchesForSingleTriplePattern() { NodeRelation[] rels = translate("?s ?p ?o", "engine/simple.n3"); Assert.assertEquals(2, rels.length); } |
URIMakerRule implements Comparator<TripleRelation> { @Override public int compare(TripleRelation o1, TripleRelation o2) { int priority1 = priority(o1); int priority2 = priority(o2); return Integer.compare(priority2, priority1); } List<TripleRelation> sortRDFRelations(Collection<TripleRelation> tripleRelations); URIMak... | @Test public void testComparator() { URIMakerRule u = new URIMakerRule(); Assert.assertEquals(0, u.compare(this.withURIPatternSubject, this.withURIPatternSubject)); Assert.assertEquals(1, u.compare(this.withURIPatternSubject, this.withURIPatternSubjectAndObject)); Assert.assertEquals(-1, u.compare(this.withURIPatternSu... |
URIMakerRule implements Comparator<TripleRelation> { public List<TripleRelation> sortRDFRelations(Collection<TripleRelation> tripleRelations) { ArrayList<TripleRelation> results = new ArrayList<>(tripleRelations); results.sort(this); return results; } List<TripleRelation> sortRDFRelations(Collection<TripleRelation> tr... | @Test public void testSort() { Collection<TripleRelation> unsorted = new ArrayList<>(Arrays.asList(this.withURIColumnSubject, this.withURIPatternSubject, this.withURIPatternSubjectAndObject, this.withURIPatternSubjectAndURIColumnObject)); Collection<TripleRelation> sorted = new ArrayList<>(Arrays.asList(this.withURIPat... |
VocabularySummarizer { public Set<Property> getAllProperties() { return properties; } VocabularySummarizer(Class<?> vocabularyJavaClass); static Set<Resource> getStandardResources(); static Set<Property> getStandardProperties(); static Set<X> getResources(Class<X> type, Class<?>... classes); static Stream<? extends Res... | @Test public void testAllPropertiesEmpty() { VocabularySummarizer vocab = new VocabularySummarizer(Object.class); Assert.assertTrue(vocab.getAllProperties().isEmpty()); }
@Test public void testAllPropertiesContainsProperty() { VocabularySummarizer vocab = new VocabularySummarizer(D2RQ.class); Assert.assertTrue(vocab.ge... |
VocabularySummarizer { public Set<Resource> getAllClasses() { return classes; } VocabularySummarizer(Class<?> vocabularyJavaClass); static Set<Resource> getStandardResources(); static Set<Property> getStandardProperties(); static Set<X> getResources(Class<X> type, Class<?>... classes); static Stream<? extends Resource>... | @Test public void testAllClassesEmpty() { VocabularySummarizer vocab = new VocabularySummarizer(Object.class); Assert.assertTrue(vocab.getAllClasses().isEmpty()); }
@Test public void testAllClassesContainsClass() { VocabularySummarizer vocab = new VocabularySummarizer(D2RQ.class); Assert.assertTrue(vocab.getAllClasses(... |
VocabularySummarizer { public String getNamespace() { return namespace; } VocabularySummarizer(Class<?> vocabularyJavaClass); static Set<Resource> getStandardResources(); static Set<Property> getStandardProperties(); static Set<X> getResources(Class<X> type, Class<?>... classes); static Stream<? extends Resource> resou... | @Test public void testGetNamespaceEmpty() { Assert.assertNull(new VocabularySummarizer(Object.class).getNamespace()); }
@Test public void testGetNamespaceD2RQ() { Assert.assertEquals(D2RQ.NS, new VocabularySummarizer(D2RQ.class).getNamespace()); }
@Test public void testGetNamespaceD2RConfig() { Assert.assertEquals(D2RC... |
VocabularySummarizer { public Collection<Resource> getUndefinedClasses(Model model) { Set<Resource> result = new HashSet<>(); StmtIterator it = model.listStatements(null, RDF.type, (RDFNode) null); while (it.hasNext()) { Statement stmt = it.nextStatement(); if (stmt.getObject().isURIResource() && stmt.getResource().get... | @Test public void testNoUndefinedClassesForEmptyModel() { VocabularySummarizer vocab = new VocabularySummarizer(D2RQ.class); Assert.assertTrue(vocab.getUndefinedClasses(ModelFactory.createDefaultModel()).isEmpty()); }
@Test public void testNoUndefinedClassesWithoutTypeStatement() { Model m = JenaModelUtils.loadTurtle("... |
VocabularySummarizer { public Collection<Property> getUndefinedProperties(Model model) { Set<Property> result = new HashSet<>(); StmtIterator it = model.listStatements(); while (it.hasNext()) { Statement stmt = it.nextStatement(); if (stmt.getPredicate().getURI().startsWith(namespace) && !properties.contains(stmt.getPr... | @Test public void testNoUndefinedPropertiesForEmptyModel() { VocabularySummarizer vocab = new VocabularySummarizer(D2RQ.class); Assert.assertTrue(vocab.getUndefinedProperties(ModelFactory.createDefaultModel()).isEmpty()); }
@Test public void testNoUndefinedPropertiesIfAllPropertiesDefined() { Model m = JenaModelUtils.l... |
MapParser { public static void fixLegacyPropertyBridges(Model m) { Iter.peek(m.listResourcesWithProperty(RDF.type, LegacyD2RQ.ObjectPropertyBridge), r -> { replace(r, D2RQ.column, D2RQ.uriColumn); replace(r, D2RQ.pattern, D2RQ.uriPattern); }).andThen(m.listResourcesWithProperty(RDF.type, LegacyD2RQ.DataPropertyBridge))... | @Test public void testFixLegacyPropertyBridges() { String ns = "http: String column = "Persons.URI"; String pattern = ns + "@@Persons.Type@@"; Model m = ModelFactory.createDefaultModel() .setNsPrefixes(MappingFactory.MAPPING).setNsPrefix("test", ns); Resource op = m.createResource(ns + "op", MapParser.LegacyD2RQ.Object... |
MapParser { public static void fixLegacyAdditionalProperty(Model m) { m.listStatements(null, LegacyD2RQ.additionalProperty, (RDFNode) null) .filterKeep(s -> s.getObject().isResource()) .toSet() .forEach(s -> { Resource classMap = s.getSubject(); Resource additional = s.getResource(); Resource p = additional.getProperty... | @Test public void testFixLegacyAdditionalProperties() { String schemaNS = "http: String mapNS = "http: Resource iri = ResourceFactory.createResource("http: Model m = ModelFactory.createDefaultModel() .setNsPrefixes(MappingFactory.MAPPING) .setNsPrefix("map", mapNS) .setNsPrefix("", schemaNS); Resource a = m.createResou... |
MapParser { public static void fixLegacyReferences(Model m) { inverse(m, LegacyD2RQ.classMap, D2RQ.clazz); inverse(m, LegacyD2RQ.propertyBridge, D2RQ.property); } static String absolutizeURI(String uri); static void insertBase(Model model, String baseURI); static void validate(Model model); static void fixLegacy(Model... | @Test public void testFixLegacyReferences() { String schemaNS = "http: String mapNS = "http: Model m = ModelFactory.createDefaultModel() .setNsPrefixes(MappingFactory.MAPPING) .setNsPrefix("owl", OWL.NS) .setNsPrefix("map", mapNS) .setNsPrefix("", schemaNS); Resource mc = m.createResource(mapNS + "PersonsClassMap", D2R... |
MapParser { public static void checkDistinctMapObjects(Model model) throws D2RQException { ensureAllDistinct(model, D2RQ.Database, D2RQ.ClassMap, D2RQ.PropertyBridge, D2RQ.TranslationTable, D2RQ.Translation); } static String absolutizeURI(String uri); static void insertBase(Model model, String baseURI); static void va... | @Test(expected = D2RQException.class) public void validateDistinctMembers() { Mapping m = MappingFactory.create() .createDatabase("x").getMapping() .createClassMap("x").getMapping(); MapParser.checkDistinctMapObjects(m.asModel()); } |
MapParser { public static void checkVocabulary(Model model) throws D2RQException { new VocabularySummarizer(D2RQ.class).assertNoUndefinedTerms(model, D2RQException.MAPPING_UNKNOWN_D2RQ_PROPERTY, D2RQException.MAPPING_UNKNOWN_D2RQ_CLASS); } static String absolutizeURI(String uri); static void insertBase(Model model, St... | @Test(expected = D2RQException.class) public void validateExternalResources() { Model m = ModelFactory.createDefaultModel(); m.createResource("x", m.createResource(D2RQ.NS + "XClass")); MapParser.checkVocabulary(m); } |
Pattern implements ValueMaker { @Override public String makeValue(ResultRow row) { int index = 0; StringBuilder result = new StringBuilder(this.firstLiteralPart); while (index < this.columns.size()) { Attribute column = columns.get(index); ColumnFunction function = columnFunctions.get(index); String value = row.get(col... | @Test public void testSimple() { Pattern pattern = new Pattern("foo@@table.col1@@baz"); Assert.assertEquals("foo1baz", pattern.makeValue(row("1"))); }
@Test public void testNull() { Pattern pattern = new Pattern("foo@@table.col1@@bar@@table.col2@@baz"); Assert.assertNull(pattern.makeValue(row("123"))); }
@Test public v... |
Pattern implements ValueMaker { public boolean matches(String value) { return !valueExpression(value).isFalse(); } Pattern(String pattern); String firstLiteralPart(); String lastLiteralPart(); boolean literalPartsMatchRegex(String regex); List<Attribute> attributes(); @Override void describeSelf(NodeSetFilter c); boole... | @Test public void testMatches() { Pattern p = new Pattern("http: Assert.assertTrue(matches(p, "http: }
@Test public void testMatchesTrivialPattern() { Pattern p = new Pattern("foobar"); assertPatternValues(p, "foobar", new HashMap<>()); Assert.assertFalse(matches(p, "fooba")); Assert.assertFalse(matches(p, "foobarb"));... |
Conjunction extends Expression { public static Expression create(Collection<Expression> expressions) { Set<Expression> elements = new HashSet<>(expressions.size()); for (Expression expression : expressions) { if (expression.isFalse()) { return Expression.FALSE; } if (expression.isTrue()) { continue; } if (expression in... | @Test public void testEmptyConjunctionIsTrue() { Assert.assertEquals(Expression.TRUE, Conjunction.create(Collections.emptySet())); }
@Test public void testSingletonConjunctionIsSelf() { Expression e = SQLExpression.create("foo"); Assert.assertEquals(e, Conjunction.create(Collections.singleton(e))); }
@Test public void ... |
Pattern implements ValueMaker { public Iterator<Object> partsIterator() { return new Iterator<Object>() { private int i = 0; @Override public boolean hasNext() { return i < columns.size() + literalParts.size() + 1; } @Override public Object next() { i++; if (i == 1) { return firstLiteralPart; } else if (i % 2 == 0) { r... | @Test public void testPartsIteratorSingleLiteral() { Iterator<Object> it = new Pattern("foo").partsIterator(); Assert.assertTrue(it.hasNext()); Assert.assertEquals("foo", it.next()); Assert.assertFalse(it.hasNext()); }
@Test public void testPartsIteratorFirstLiteralThenColumn() { Iterator<Object> it = new Pattern("foo@... |
Pattern implements ValueMaker { @Override public String toString() { return "Pattern(" + this.pattern + ")"; } Pattern(String pattern); String firstLiteralPart(); String lastLiteralPart(); boolean literalPartsMatchRegex(String regex); List<Attribute> attributes(); @Override void describeSelf(NodeSetFilter c); boolean m... | @Test public void testToString() { Assert.assertEquals("Pattern(foo@@table.col1@@)", new Pattern("foo@@table.col1@@").toString()); } |
Pattern implements ValueMaker { @Override public int hashCode() { return this.pattern.hashCode(); } Pattern(String pattern); String firstLiteralPart(); String lastLiteralPart(); boolean literalPartsMatchRegex(String regex); List<Attribute> attributes(); @Override void describeSelf(NodeSetFilter c); boolean matches(Stri... | @Test public void testSamePatternsAreEqual() { Pattern p1 = new Pattern("foo@@table.col1@@"); Pattern p2 = new Pattern("foo@@table.col1@@"); Assert.assertEquals(p1, p2); Assert.assertEquals(p2, p1); Assert.assertEquals(p1.hashCode(), p2.hashCode()); }
@Test public void testPatternsWithDifferentColumnsAreNotEqual() { Pa... |
Pattern implements ValueMaker { public boolean isEquivalentTo(Pattern p) { return this.firstLiteralPart.equals(p.firstLiteralPart) && this.literalParts.equals(p.literalParts) && this.columnFunctions.equals(p.columnFunctions); } Pattern(String pattern); String firstLiteralPart(); String lastLiteralPart(); boolean litera... | @Test public void testIdenticalPatternsAreCompatible() { Pattern p1 = new Pattern("foo@@table.col1@@"); Pattern p2 = new Pattern("foo@@table.col1@@"); Assert.assertTrue(p1.isEquivalentTo(p2)); Assert.assertTrue(p2.isEquivalentTo(p1)); }
@Test public void testPatternsWithDifferentColumnNamesAreCompatible() { Pattern p1 ... |
Pattern implements ValueMaker { public boolean literalPartsMatchRegex(String regex) { if (!this.firstLiteralPart.matches(regex)) { return false; } for (String literalPart : literalParts) { if (!literalPart.matches(regex)) { return false; } } return true; } Pattern(String pattern); String firstLiteralPart(); String last... | @Test public void testLiteralPatternsMatchTrivialRegex() { Assert.assertTrue(new Pattern("asdf").literalPartsMatchRegex(".*")); }
@Test public void testLiteralPatternsDontMatchTrivialRegex() { Assert.assertFalse(new Pattern("asdf").literalPartsMatchRegex("foo")); }
@Test public void testLiteralPatternRegexIsAnchored() ... |
Conjunction extends Expression { @Override public String toString() { List<String> fragments = new ArrayList<>(this.expressions.size()); for (Expression expression : expressions) { fragments.add(expression.toString()); } Collections.sort(fragments); StringBuilder result = new StringBuilder("Conjunction("); Iterator<Str... | @Test public void testToString() { Assert.assertEquals("Conjunction(SQL(papers.publish = 1), SQL(papers.rating > 4))", conjunction12.toString()); } |
Pattern implements ValueMaker { public String firstLiteralPart() { return firstLiteralPart; } Pattern(String pattern); String firstLiteralPart(); String lastLiteralPart(); boolean literalPartsMatchRegex(String regex); List<Attribute> attributes(); @Override void describeSelf(NodeSetFilter c); boolean matches(String val... | @Test public void testTrivialPatternFirstPart() { Assert.assertEquals("aaa", new Pattern("aaa").firstLiteralPart()); }
@Test public void testEmptyFirstPart() { Assert.assertEquals("", new Pattern("@@table.col1@@aaa").firstLiteralPart()); } |
Pattern implements ValueMaker { public String lastLiteralPart() { if (literalParts.isEmpty()) { return firstLiteralPart; } return literalParts.get(literalParts.size() - 1); } Pattern(String pattern); String firstLiteralPart(); String lastLiteralPart(); boolean literalPartsMatchRegex(String regex); List<Attribute> attri... | @Test public void testTrivialPatternLastPart() { Assert.assertEquals("aaa", new Pattern("aaa").lastLiteralPart()); }
@Test public void testEmptyLastPart() { Assert.assertEquals("", new Pattern("aaa@@table.col1@@").lastLiteralPart()); } |
Conjunction extends Expression { @Override public int hashCode() { return this.expressions.hashCode(); } private Conjunction(Set<Expression> expressions); static Expression create(Collection<Expression> expressions); @Override boolean isTrue(); @Override boolean isFalse(); @Override Set<Attribute> attributes(); @Overr... | @Test public void testOrderDoesNotAffectEquality() { Assert.assertEquals(conjunction12, conjunction21); Assert.assertEquals(conjunction12.hashCode(), conjunction21.hashCode()); } |
Concatenation extends Expression { public static Expression create(List<Expression> expressions) { List<Expression> nonEmpty = new ArrayList<>(expressions.size()); for (Expression expression : expressions) { if (expression instanceof Constant && "".equals(((Constant) expression).value())) { continue; } nonEmpty.add(exp... | @Test public void testCreateEmpty() { Assert.assertEquals(new Constant(""), Concatenation.create(Collections.emptyList())); }
@Test public void testCreateOnePart() { Expression expr = new AttributeExpr(new Attribute(null, "table", "col")); Assert.assertEquals(expr, Concatenation.create(Collections.singletonList(expr)))... |
SQLExpression extends Expression { public static Expression create(String sql) { sql = sql.trim(); if ("1".equals(sql)) { return Expression.TRUE; } if ("0".equals(sql)) { return Expression.FALSE; } return new SQLExpression(sql); } private SQLExpression(String expression); static Expression create(String sql); @Overrid... | @Test public void testCreate() { Expression e = SQLExpression.create("papers.publish = 1"); Assert.assertEquals("SQL(papers.publish = 1)", e.toString()); Assert.assertFalse(e.isTrue()); Assert.assertFalse(e.isFalse()); } |
SQLExpression extends Expression { @Override public String toString() { return "SQL(" + this.expression + ")"; } private SQLExpression(String expression); static Expression create(String sql); @Override boolean isTrue(); @Override boolean isFalse(); @Override Set<Attribute> attributes(); @Override Expression renameAtt... | @Test public void testToString() { Expression e = SQLExpression.create("papers.publish = 1"); Assert.assertEquals("SQL(papers.publish = 1)", e.toString()); } |
Expression { public abstract String toSQL(ConnectedDB database, AliasMap aliases); abstract boolean isTrue(); abstract boolean isFalse(); abstract Set<Attribute> attributes(); abstract Expression renameAttributes(ColumnRenamer columnRenamer); abstract String toSQL(ConnectedDB database, AliasMap aliases); Expression an... | @Test public void testConstantToSQL() { Assert.assertEquals("'foo'", new Constant("foo").toSQL(DummyDB.create(), AliasMap.NO_ALIASES)); }
@Test public void testConstantToSQLWithType() { Attribute attribute = SQL.parseAttribute("table.col1"); ConnectedDB db = DummyDB.create(Collections.singletonMap("table.col1", Generic... |
Expression { public abstract Expression renameAttributes(ColumnRenamer columnRenamer); abstract boolean isTrue(); abstract boolean isFalse(); abstract Set<Attribute> attributes(); abstract Expression renameAttributes(ColumnRenamer columnRenamer); abstract String toSQL(ConnectedDB database, AliasMap aliases); Expressio... | @Test public void testConstantTypeAttributeIsRenamed() { Attribute attribute = SQL.parseAttribute("table.col1"); Assert.assertEquals("Constant(42@alias.col1)", new Constant("42", attribute).renameAttributes(aliases).toString()); } |
Relation implements RelationalOperators { public boolean isTrivial() { return projections().isEmpty() && condition().isTrue() && joinConditions().isEmpty(); } static Relation createSimpleRelation(
ConnectedDB database, Attribute[] attributes); abstract ConnectedDB database(); abstract AliasMap aliases(); a... | @Test public void testTrueRelationIsTrivial() { Assert.assertTrue(Relation.TRUE.isTrivial()); }
@Test public void testQueryWithSelectColumnsIsNotTrivial() { Assert.assertFalse(rel1.isTrivial()); } |
Attribute implements ProjectionSpec { @Override public String toString() { return "@@" + this.qualifiedName + "@@"; } Attribute(String schemaName, String tableName, String attributeName); Attribute(RelationName relationName, String attributeName); String qualifiedName(); @Override String toSQL(ConnectedDB database, Al... | @Test public void testAttributeToString() { Assert.assertEquals("@@foo.bar@@", new Attribute(null, "foo", "bar").toString()); Assert.assertEquals("@@schema.foo.bar@@", new Attribute("schema", "foo", "bar").toString()); }
@Test public void testRelationNameToString() { Assert.assertEquals("table", new RelationName(null, ... |
Attribute implements ProjectionSpec { @Override public int compareTo(ProjectionSpec other) { if (!(other instanceof Attribute)) { return -1; } Attribute otherAttribute = (Attribute) other; int i = this.relationName.compareTo(otherAttribute.relationName); if (i != 0) { return i; } return this.attributeName.compareTo(oth... | @Test public void testCompareSameAttribute() { Assert.assertEquals(0, fooCol1.compareTo(fooCol1)); }
@Test public void testCompareSameTableDifferentAttribute() { Assert.assertTrue(fooCol1.compareTo(fooCol2) < 0); Assert.assertTrue(fooCol2.compareTo(fooCol1) > 0); }
@Test public void testCompareSameAttributeDifferentTab... |
Attribute implements ProjectionSpec { @Override public int hashCode() { return this.qualifiedName.hashCode(); } Attribute(String schemaName, String tableName, String attributeName); Attribute(RelationName relationName, String attributeName); String qualifiedName(); @Override String toSQL(ConnectedDB database, AliasMap... | @Test public void testSameRelationNameIsEqual() { Assert.assertEquals(table1, table1b); Assert.assertEquals(table1b, table1); Assert.assertEquals(table1.hashCode(), table1b.hashCode()); }
@Test public void testDifferentRelationNamesAreNotEqual() { Assert.assertNotEquals(table1, table2); Assert.assertNotEquals(table2, t... |
Attribute implements ProjectionSpec { public String qualifiedName() { return this.qualifiedName; } Attribute(String schemaName, String tableName, String attributeName); Attribute(RelationName relationName, String attributeName); String qualifiedName(); @Override String toSQL(ConnectedDB database, AliasMap aliases); St... | @Test public void testRelationNameWithPrefixNoSchema() { Assert.assertEquals("T42_table1", table1.withPrefix(42).qualifiedName()); }
@Test public void testRelationNameWithPrefixWithSchema() { Assert.assertEquals("T42_x_table1", xTable1.withPrefix(42).qualifiedName()); } |
ColumnRenamer { public abstract Attribute applyTo(Attribute original); abstract Attribute applyTo(Attribute original); Join applyTo(Join original); Expression applyTo(Expression original); Set<Join> applyToJoinSet(Set<Join> joins); ProjectionSpec applyTo(ProjectionSpec original); Set<ProjectionSpec> applyToProjectionS... | @Test public void testApplyToUnmappedColumnReturnsSameColumn() { Assert.assertEquals(col3, this.col1ToCol2.applyTo(col3)); }
@Test public void testApplyToMappedColumnReturnsNewName() { Assert.assertEquals(col2, this.col1ToCol2.applyTo(col1)); }
@Test public void testApplyToNewNameReturnsNewName() { Assert.assertEquals(... |
AliasMap extends ColumnRenamer { public RelationName applyTo(RelationName original) { if (!hasAlias(original)) { return original; } Alias alias = this.byOriginal.get(original); return alias.alias(); } AliasMap(Collection<Alias> aliases); static AliasMap create1(RelationName original, RelationName alias); boolean isAlia... | @Test public void testApplyToColumn() { Assert.assertEquals(baz_col1, this.fooAsBarMap.applyTo(baz_col1)); Assert.assertEquals(bar_col1, this.fooAsBarMap.applyTo(foo_col1)); Assert.assertEquals(bar_col1, this.fooAsBarMap.applyTo(bar_col1)); }
@Test public void testApplyToSQLExpression() { Assert.assertEquals(SQLExpress... |
AliasMap extends ColumnRenamer { public RelationName originalOf(RelationName name) { if (!isAlias(name)) { return name; } Alias alias = this.byAlias.get(name); return alias.original(); } AliasMap(Collection<Alias> aliases); static AliasMap create1(RelationName original, RelationName alias); boolean isAlias(RelationName... | @Test public void testOriginalOfColumn() { Assert.assertEquals(baz_col1, this.fooAsBarMap.originalOf(baz_col1)); Assert.assertEquals(foo_col1, this.fooAsBarMap.originalOf(foo_col1)); Assert.assertEquals(foo_col1, this.fooAsBarMap.originalOf(bar_col1)); }
@Test public void testOriginalOfAliasEmpty() { Assert.assertEqual... |
AliasMap extends ColumnRenamer { @Override public int hashCode() { return this.byAlias.hashCode(); } AliasMap(Collection<Alias> aliases); static AliasMap create1(RelationName original, RelationName alias); boolean isAlias(RelationName name); boolean hasAlias(RelationName original); RelationName applyTo(RelationName ori... | @Test public void testEqualMapsHaveSameHashCode() { AliasMap m1 = new AliasMap(new ArrayList<>()); AliasMap m2 = new AliasMap(new ArrayList<>()); Assert.assertEquals(m1.hashCode(), m2.hashCode()); }
@Test public void testAliasEquals() { Alias fooAsBar2 = new Alias(foo, bar); Assert.assertEquals(fooAsBar, fooAsBar2); As... |
AliasMap extends ColumnRenamer { @Override public String toString() { StringBuilder result = new StringBuilder(); result.append("AliasMap("); List<RelationName> tables = new ArrayList<>(this.byAlias.keySet()); Collections.sort(tables); Iterator<RelationName> it = tables.iterator(); while (it.hasNext()) { result.append(... | @Test public void testAliasToString() { Assert.assertEquals("foo AS bar", fooAsBar.toString()); }
@Test public void testToStringEmpty() { Assert.assertEquals("AliasMap()", AliasMap.NO_ALIASES.toString()); }
@Test public void testToStringOneAlias() { Assert.assertEquals("AliasMap(foo AS bar)", fooAsBarMap.toString()); }... |
Join { @Override public String toString() { StringBuilder result = new StringBuilder("Join("); Iterator<Attribute> it = this.attributes1.iterator(); while (it.hasNext()) { Attribute attribute = it.next(); result.append(attribute.qualifiedName()); if (it.hasNext()) { result.append(", "); } } result.append(joinDirection ... | @Test public void testToString() { Join join = new Join(table1foo, table2foo, Join.DIRECTION_UNDIRECTED); Assert.assertEquals("Join(table1.foo <=> table2.foo)", join.toString()); }
@Test public void testToStringRetainsTableOrder() { Join join = new Join(table2foo, table1foo, Join.DIRECTION_RIGHT); Assert.assertEquals("... |
Join { public Join renameColumns(ColumnRenamer columnRenamer) { List<Attribute> oneSide = new ArrayList<>(); List<Attribute> otherSide = new ArrayList<>(); for (Attribute column : attributes1) { oneSide.add(columnRenamer.applyTo(column)); otherSide.add(columnRenamer.applyTo(equalAttribute(column))); } return new Join(o... | @Test public void testRenameColumns() { ColumnRenamer renamer = new ColumnRenamerMap(Collections.singletonMap(table1foo, table1bar)); Join join = new Join(table1foo, table2foo, Join.DIRECTION_RIGHT); Assert.assertEquals("Join(table1.bar => table2.foo)", join.renameColumns(renamer).toString()); } |
Join { public RelationName table1() { return this.table1; } Join(Attribute oneSide, Attribute otherSide, int joinDirection); Join(List<Attribute> oneSideAttributes, List<Attribute> otherSideAttributes, int joinDirection); boolean isSameTable(); boolean containsColumn(Attribute column); RelationName table1(); RelationN... | @Test public void testTableOrderIsRetained() { Assert.assertEquals(table1, new Join(table1foo, table2foo, Join.DIRECTION_RIGHT).table1()); Assert.assertEquals(table2, new Join(table2foo, table1foo, Join.DIRECTION_RIGHT).table1()); } |
Join { @Override public int hashCode() { switch (this.joinDirection) { case DIRECTION_RIGHT: return 31 * (this.attributes1.hashCode() ^ this.attributes2.hashCode()); case DIRECTION_LEFT: return 31 * (this.attributes2.hashCode() ^ this.attributes1.hashCode()); case DIRECTION_UNDIRECTED: default: return 31 * (this.attrib... | @Test public void testJoinOverSameAttributesIsEqual() { Join j1 = new Join(table1foo, table2foo, Join.DIRECTION_RIGHT); Join j2 = new Join(table1foo, table2foo, Join.DIRECTION_RIGHT); Assert.assertEquals(j1, j2); Assert.assertEquals(j2, j1); Assert.assertEquals(j1.hashCode(), j2.hashCode()); }
@Test public void testSid... |
FilterParser { public List<List<IdentifierMatcher>> parse() throws ParseException { eatSeparators(); while (!atEnd()) { List<IdentifierMatcher> list = new ArrayList<>(); while (!atEnd()) { if (current() == '/') { list.add(parseRegex()); } else { list.add(parseIdentifier()); } if (!atEnd() && atFilterTerminator()) { bre... | @Test public void testEmpty() throws ParseException { Assert.assertEquals("", toString(new FilterParser("").parse())); }
@Test public void testSimple() throws ParseException { Assert.assertEquals("'foo'", toString(new FilterParser("foo").parse())); }
@Test public void testMultipleStrings() throws ParseException { Asser... |
FilterParser { public Filter parseSchemaFilter() throws ParseException { List<Filter> result = new ArrayList<>(); for (List<IdentifierMatcher> list : parse()) { if (list.size() != 1) { throw new ParseException("Syntax error in schema filter list; expected list of comma- or newline-separated schema names: '" + s + "'");... | @Test public void testParseAsSchemaFilter() throws ParseException { Filter result = new FilterParser("schema1,schema2").parseSchemaFilter(); Assert.assertTrue(result.matchesSchema("schema1")); Assert.assertTrue(result.matchesSchema("schema2")); Assert.assertFalse(result.matchesSchema("schema3")); Assert.assertFalse(res... |
NiFIAtlasHook extends AtlasHook { public void createLineageToKafkaTopic() throws Exception { final List<HookNotification.HookNotificationMessage> messages = new ArrayList<>(); final Referenceable topic = new Referenceable("kafka_topic"); topic.set(ATTR_NAME, "notification"); topic.set("topic", "notification"); topic.se... | @Test public void test() throws Exception { final NiFIAtlasHook hook = new NiFIAtlasHook(); hook.createLineageToKafkaTopic(); } |
HBaseTable extends AbstractNiFiProvenanceEventAnalyzer { @Override public DataSetRefs analyze(AnalysisContext context, ProvenanceEventRecord event) { final Matcher uriMatcher = URI_PATTERN.matcher(event.getTransitUri()); if (!uriMatcher.matches()) { logger.warn("Unexpected transit URI: {}", new Object[]{event.getTransi... | @Test public void testHBaseTable() { final String processorName = "FetchHBaseRow"; final String transitUri = "hbase: final ProvenanceEventRecord record = Mockito.mock(ProvenanceEventRecord.class); when(record.getComponentType()).thenReturn(processorName); when(record.getTransitUri()).thenReturn(transitUri); when(record... |
CreateObscureInputDataSet extends AbstractNiFiProvenanceEventAnalyzer { @Override public DataSetRefs analyze(AnalysisContext context, ProvenanceEventRecord event) { final String componentId = event.getComponentId(); final List<ConnectionStatus> incomingConnections = context.findConnectionTo(componentId); if (incomingCo... | @Test public void testGenerateFlowFile() { final String processorName = "GenerateFlowFile"; final String processorId = "processor-1234"; final ProvenanceEventRecord record = Mockito.mock(ProvenanceEventRecord.class); when(record.getComponentType()).thenReturn(processorName); when(record.getComponentId()).thenReturn(pro... |
HDFSPath extends AbstractNiFiProvenanceEventAnalyzer { @Override public DataSetRefs analyze(AnalysisContext context, ProvenanceEventRecord event) { final Referenceable ref = new Referenceable(TYPE); final URI uri = parseUri(event.getTransitUri()); final String clusterName = context.getClusterResolver().fromHostname(uri... | @Test public void testHDFSPath() { final String processorName = "PutHDFS"; final String transitUri = "hdfs: final ProvenanceEventRecord record = Mockito.mock(ProvenanceEventRecord.class); when(record.getComponentType()).thenReturn(processorName); when(record.getTransitUri()).thenReturn(transitUri); when(record.getEvent... |
KafkaTopic extends AbstractNiFiProvenanceEventAnalyzer { @Override public DataSetRefs analyze(AnalysisContext context, ProvenanceEventRecord event) { final Referenceable ref = new Referenceable(TYPE); final String transitUri = event.getTransitUri(); final Matcher uriMatcher = URI_PATTERN.matcher(transitUri); if (!uriMa... | @Test public void testPublishKafka() { final String processorName = "PublishKafka"; final String transitUri = "PLAINTEXT: final ProvenanceEventRecord record = Mockito.mock(ProvenanceEventRecord.class); when(record.getComponentType()).thenReturn(processorName); when(record.getTransitUri()).thenReturn(transitUri); when(r... |
InputPort extends AbstractFileAnalyzer { @Override public DataSetRefs analyze(AnalysisContext context, ProvenanceEventRecord event) { final List<ConnectionStatus> connections = context.findConnectionFrom(event.getComponentId()); if (connections == null || connections.isEmpty()) { logger.warn("Connection was not found: ... | @Test public void testInputPort() { final String processorName = "Input Port"; ConnectionStatus con1 = Mockito.mock(ConnectionStatus.class); when(con1.getDestinationId()).thenReturn("101"); List<ConnectionStatus> connectionStatuses = new ArrayList<>(); connectionStatuses.add(con1); final String componentId = "100"; fin... |
ByFileLineageStrategy implements LineageEventProcessor { public void processEvent (ProvenanceEventRecord event, NiFiFlow nifiFlow, AnalysisContext analysisContext) { try { if (event.getEventType() == ProvenanceEventType.CLONE) { createParentProcess (event, nifiFlow); ProcessorStatus pr = nifiFlow.getProcessors().get(ev... | @Test public void testClone() throws IOException { ProcessGroupStatus root = new ProcessGroupStatus(); MockComponentLog logger = new MockComponentLog("0", this); NiFIAtlasHook atlasHook = new NiFIAtlasHook() { protected void notifyEntities(List<HookNotification.HookNotificationMessage> messages) { assertEquals(4, messa... |
NiFiFlowAnalyzer { public NiFiFlow analyzeProcessGroup(AtlasVariables atlasVariables, ReportingContext context) throws IOException { final ProcessGroupStatus rootProcessGroup = context.getEventAccess().getGroupStatus("root"); final String flowName = rootProcessGroup.getName(); final String nifiUrlForAtlasMetadata = atl... | @Test public void testEmptyFlow() throws Exception { ReportingContext reportingContext = Mockito.mock(ReportingContext.class); EventAccess eventAccess = Mockito.mock(EventAccess.class); ProcessGroupStatus rootPG = createEmptyProcessGroupStatus(); when(reportingContext.getEventAccess()).thenReturn(eventAccess); when(eve... |
PutHiveStreaming extends AbstractHiveAnalyzer { @Override public DataSetRefs analyze(AnalysisContext context, ProvenanceEventRecord event) { final URI uri = parseUri(event.getTransitUri()); final String clusterName = context.getClusterResolver().fromHostname(uri.getHost()); final Set<Tuple<String, String>> outputTables... | @Test public void testTableLineage() { final String processorName = "PutHiveStreaming"; final String transitUri = "thrift: final ProvenanceEventRecord record = Mockito.mock(ProvenanceEventRecord.class); when(record.getComponentType()).thenReturn(processorName); when(record.getTransitUri()).thenReturn(transitUri); when(... |
Hive2JDBC extends AbstractHiveAnalyzer { @Override public DataSetRefs analyze(AnalysisContext context, ProvenanceEventRecord event) { final String transitUri = event.getTransitUri().replaceFirst("^jdbc:hive2", "jdbc-hive2"); final URI uri = parseUri(transitUri); final String clusterName = context.getClusterResolver().f... | @Test public void testDatabaseLineage() { final String processorName = "PutHiveQL"; final String transitUri = "jdbc:hive2: final ProvenanceEventRecord record = Mockito.mock(ProvenanceEventRecord.class); when(record.getComponentType()).thenReturn(processorName); when(record.getTransitUri()).thenReturn(transitUri); when(... |
GetPutFile extends AbstractFileAnalyzer { @Override public DataSetRefs analyze(AnalysisContext context, ProvenanceEventRecord event) { final URI uri = parseUri(event.getTransitUri()); final String clusterName = context.getClusterResolver().fromHostname(uri.getHost()); final DataSetRefs refs = new DataSetRefs(event.getC... | @Test public void testGetFile() { final String processorName = "GetFile"; final String transitUri = "file:/var/data/landing/sample_z"; final ProvenanceEventRecord record = Mockito.mock(ProvenanceEventRecord.class); when(record.getComponentType()).thenReturn(processorName); when(record.getTransitUri()).thenReturn(transi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.