target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test(expected = AttributeParseException.class) public void operation_length_too_long() { AddressPrefixRange.parse("77.74.152.0/23^33"); } | public static AddressPrefixRange parse(final CIString value) { return parse(value.toString()); } | AddressPrefixRange { public static AddressPrefixRange parse(final CIString value) { return parse(value.toString()); } } | AddressPrefixRange { public static AddressPrefixRange parse(final CIString value) { return parse(value.toString()); } private AddressPrefixRange(final String value, final IpInterval ipInterval, final RangeOperation rangeOperation); } | AddressPrefixRange { public static AddressPrefixRange parse(final CIString value) { return parse(value.toString()); } private AddressPrefixRange(final String value, final IpInterval ipInterval, final RangeOperation rangeOperation); IpInterval getIpInterval(); RangeOperation getRangeOperation(); @Override String toString(); @SuppressWarnings("unchecked") BoundaryCheckResult checkWithinBounds(final IpInterval bounds); @SuppressWarnings("unchecked") BoundaryCheckResult checkRange(final IpInterval contained); static AddressPrefixRange parse(final CIString value); static AddressPrefixRange parse(final String value); } | AddressPrefixRange { public static AddressPrefixRange parse(final CIString value) { return parse(value.toString()); } private AddressPrefixRange(final String value, final IpInterval ipInterval, final RangeOperation rangeOperation); IpInterval getIpInterval(); RangeOperation getRangeOperation(); @Override String toString(); @SuppressWarnings("unchecked") BoundaryCheckResult checkWithinBounds(final IpInterval bounds); @SuppressWarnings("unchecked") BoundaryCheckResult checkRange(final IpInterval contained); static AddressPrefixRange parse(final CIString value); static AddressPrefixRange parse(final String value); } |
@Test(expected = AttributeParseException.class) public void n_lower_than_prefix_range() { AddressPrefixRange.parse("77.74.152.0/23^22"); } | public static AddressPrefixRange parse(final CIString value) { return parse(value.toString()); } | AddressPrefixRange { public static AddressPrefixRange parse(final CIString value) { return parse(value.toString()); } } | AddressPrefixRange { public static AddressPrefixRange parse(final CIString value) { return parse(value.toString()); } private AddressPrefixRange(final String value, final IpInterval ipInterval, final RangeOperation rangeOperation); } | AddressPrefixRange { public static AddressPrefixRange parse(final CIString value) { return parse(value.toString()); } private AddressPrefixRange(final String value, final IpInterval ipInterval, final RangeOperation rangeOperation); IpInterval getIpInterval(); RangeOperation getRangeOperation(); @Override String toString(); @SuppressWarnings("unchecked") BoundaryCheckResult checkWithinBounds(final IpInterval bounds); @SuppressWarnings("unchecked") BoundaryCheckResult checkRange(final IpInterval contained); static AddressPrefixRange parse(final CIString value); static AddressPrefixRange parse(final String value); } | AddressPrefixRange { public static AddressPrefixRange parse(final CIString value) { return parse(value.toString()); } private AddressPrefixRange(final String value, final IpInterval ipInterval, final RangeOperation rangeOperation); IpInterval getIpInterval(); RangeOperation getRangeOperation(); @Override String toString(); @SuppressWarnings("unchecked") BoundaryCheckResult checkWithinBounds(final IpInterval bounds); @SuppressWarnings("unchecked") BoundaryCheckResult checkRange(final IpInterval contained); static AddressPrefixRange parse(final CIString value); static AddressPrefixRange parse(final String value); } |
@Test(expected = AttributeParseException.class) public void empty() { NServer.parse(""); } | public static NServer parse(final CIString value) { return parse(value.toString()); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); CIString getHostname(); @CheckForNull IpInterval getIpInterval(); @Override String toString(); static NServer parse(final CIString value); static NServer parse(final String value); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); CIString getHostname(); @CheckForNull IpInterval getIpInterval(); @Override String toString(); static NServer parse(final CIString value); static NServer parse(final String value); } |
@Test(expected = AttributeParseException.class) public void hostname_invalid() { NServer.parse("$"); } | public static NServer parse(final CIString value) { return parse(value.toString()); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); CIString getHostname(); @CheckForNull IpInterval getIpInterval(); @Override String toString(); static NServer parse(final CIString value); static NServer parse(final String value); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); CIString getHostname(); @CheckForNull IpInterval getIpInterval(); @Override String toString(); static NServer parse(final CIString value); static NServer parse(final String value); } |
@Test(expected = AttributeParseException.class) public void hostname_and_ipv4_range_24() { NServer.parse("dns.comcor.ru 194.0.0.0/24"); } | public static NServer parse(final CIString value) { return parse(value.toString()); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); CIString getHostname(); @CheckForNull IpInterval getIpInterval(); @Override String toString(); static NServer parse(final CIString value); static NServer parse(final String value); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); CIString getHostname(); @CheckForNull IpInterval getIpInterval(); @Override String toString(); static NServer parse(final CIString value); static NServer parse(final String value); } |
@Test(expected = AttributeParseException.class) public void hostname_and_ipv4_list() { NServer.parse("dns.comcor.ru 194.0.0.0 194.0.0.0"); } | public static NServer parse(final CIString value) { return parse(value.toString()); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); CIString getHostname(); @CheckForNull IpInterval getIpInterval(); @Override String toString(); static NServer parse(final CIString value); static NServer parse(final String value); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); CIString getHostname(); @CheckForNull IpInterval getIpInterval(); @Override String toString(); static NServer parse(final CIString value); static NServer parse(final String value); } |
@Test public void process_throws_exception() throws IOException { when(grsSource.getName()).thenReturn(ciString("APNIC-GRS")); doThrow(RuntimeException.class).when(grsSource).handleObjects(any(File.class), any(ObjectHandler.class)); try { subject.grsImport(grsSource, false); fail("Expected RuntimeException"); } catch (RuntimeException e) { verify(grsSource).handleObjects(any(File.class), any(ObjectHandler.class)); } } | void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } |
@Test(expected = AttributeParseException.class) public void hostname_and_invalid_ip() { NServer.parse("dns.comcor.ru dns.comcor.ru"); } | public static NServer parse(final CIString value) { return parse(value.toString()); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); CIString getHostname(); @CheckForNull IpInterval getIpInterval(); @Override String toString(); static NServer parse(final CIString value); static NServer parse(final String value); } | NServer { public static NServer parse(final CIString value) { return parse(value.toString()); } private NServer(final CIString hostname, final IpInterval ipInterval); CIString getHostname(); @CheckForNull IpInterval getIpInterval(); @Override String toString(); static NServer parse(final CIString value); static NServer parse(final String value); } |
@Test(expected = AttributeParseException.class) public void empty() { Domain.parse(""); } | public static Domain parse(final CIString value) { return parse(value.toString()); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); CIString getValue(); Type getType(); @CheckForNull IpInterval<?> getReverseIp(); boolean endsWithDomain(final CIString hostname); static Domain parse(final CIString value); static Domain parse(final String domain); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); CIString getValue(); Type getType(); @CheckForNull IpInterval<?> getReverseIp(); boolean endsWithDomain(final CIString hostname); static Domain parse(final CIString value); static Domain parse(final String domain); } |
@Test(expected = AttributeParseException.class) public void hostname() { Domain.parse("hostname"); } | public static Domain parse(final CIString value) { return parse(value.toString()); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); CIString getValue(); Type getType(); @CheckForNull IpInterval<?> getReverseIp(); boolean endsWithDomain(final CIString hostname); static Domain parse(final CIString value); static Domain parse(final String domain); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); CIString getValue(); Type getType(); @CheckForNull IpInterval<?> getReverseIp(); boolean endsWithDomain(final CIString hostname); static Domain parse(final CIString value); static Domain parse(final String domain); } |
@Test(expected = AttributeParseException.class) public void ipv4_dash_invalid_position() { Domain.parse("0-127.10.10.in-addr.arpa"); } | public static Domain parse(final CIString value) { return parse(value.toString()); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); CIString getValue(); Type getType(); @CheckForNull IpInterval<?> getReverseIp(); boolean endsWithDomain(final CIString hostname); static Domain parse(final CIString value); static Domain parse(final String domain); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); CIString getValue(); Type getType(); @CheckForNull IpInterval<?> getReverseIp(); boolean endsWithDomain(final CIString hostname); static Domain parse(final CIString value); static Domain parse(final String domain); } |
@Test(expected = AttributeParseException.class) public void ipv4_dash_range_0_255() { Domain.parse("0-255.10.10.in-addr.arpa"); } | public static Domain parse(final CIString value) { return parse(value.toString()); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); CIString getValue(); Type getType(); @CheckForNull IpInterval<?> getReverseIp(); boolean endsWithDomain(final CIString hostname); static Domain parse(final CIString value); static Domain parse(final String domain); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); CIString getValue(); Type getType(); @CheckForNull IpInterval<?> getReverseIp(); boolean endsWithDomain(final CIString hostname); static Domain parse(final CIString value); static Domain parse(final String domain); } |
@Test(expected = AttributeParseException.class) public void ipv4_dash_range_start_is_range_end() { Domain.parse("1-1.10.10.in-addr.arpa"); } | public static Domain parse(final CIString value) { return parse(value.toString()); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); CIString getValue(); Type getType(); @CheckForNull IpInterval<?> getReverseIp(); boolean endsWithDomain(final CIString hostname); static Domain parse(final CIString value); static Domain parse(final String domain); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); CIString getValue(); Type getType(); @CheckForNull IpInterval<?> getReverseIp(); boolean endsWithDomain(final CIString hostname); static Domain parse(final CIString value); static Domain parse(final String domain); } |
@Test(expected = AttributeParseException.class) public void suffix() { Domain.parse("200.193.193.193.some-suffix."); } | public static Domain parse(final CIString value) { return parse(value.toString()); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); CIString getValue(); Type getType(); @CheckForNull IpInterval<?> getReverseIp(); boolean endsWithDomain(final CIString hostname); static Domain parse(final CIString value); static Domain parse(final String domain); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); CIString getValue(); Type getType(); @CheckForNull IpInterval<?> getReverseIp(); boolean endsWithDomain(final CIString hostname); static Domain parse(final CIString value); static Domain parse(final String domain); } |
@Test(expected = AttributeParseException.class) public void suffix_almost_correct() { Domain.parse("200.193.193.in-addraarpa"); } | public static Domain parse(final CIString value) { return parse(value.toString()); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); CIString getValue(); Type getType(); @CheckForNull IpInterval<?> getReverseIp(); boolean endsWithDomain(final CIString hostname); static Domain parse(final CIString value); static Domain parse(final String domain); } | Domain { public static Domain parse(final CIString value) { return parse(value.toString()); } private Domain(final CIString value, final IpInterval<?> reverseIp, final Type type, final boolean dashNotation); CIString getValue(); Type getType(); @CheckForNull IpInterval<?> getReverseIp(); boolean endsWithDomain(final CIString hostname); static Domain parse(final CIString value); static Domain parse(final String domain); } |
@Test public void empty() { assertThat(subject.getMessages().getAllMessages(), hasSize(0)); } | public Messages getMessages() { return messages; } | ObjectMessages { public Messages getMessages() { return messages; } } | ObjectMessages { public Messages getMessages() { return messages; } } | ObjectMessages { public Messages getMessages() { return messages; } Messages getMessages(); Map<RpslAttribute, Messages> getAttributeMessages(); boolean contains(final Message message); void addMessage(final Message message); void addMessage(final RpslAttribute attribute, final Message message); Messages getMessages(final RpslAttribute attribute); boolean hasErrors(); boolean hasMessages(); int getErrorCount(); void addAll(final ObjectMessages objectMessages); @Override String toString(); } | ObjectMessages { public Messages getMessages() { return messages; } Messages getMessages(); Map<RpslAttribute, Messages> getAttributeMessages(); boolean contains(final Message message); void addMessage(final Message message); void addMessage(final RpslAttribute attribute, final Message message); Messages getMessages(final RpslAttribute attribute); boolean hasErrors(); boolean hasMessages(); int getErrorCount(); void addAll(final ObjectMessages objectMessages); @Override String toString(); } |
@Test public void addAll() { final RpslAttribute attribute = object.getAttributes().get(0); final ObjectMessages other = new ObjectMessages(); other.addMessage(error); other.addMessage(attribute, warning); subject.addAll(other); assertThat(subject.contains(error), is(true)); assertThat(subject.getMessages(attribute).getWarnings(), contains(warning)); } | public void addAll(final ObjectMessages objectMessages) { messages.addAll(objectMessages.messages); for (final Map.Entry<RpslAttribute, Messages> entry : objectMessages.attributeMessages.entrySet()) { getMessages(entry.getKey()).addAll(entry.getValue()); } } | ObjectMessages { public void addAll(final ObjectMessages objectMessages) { messages.addAll(objectMessages.messages); for (final Map.Entry<RpslAttribute, Messages> entry : objectMessages.attributeMessages.entrySet()) { getMessages(entry.getKey()).addAll(entry.getValue()); } } } | ObjectMessages { public void addAll(final ObjectMessages objectMessages) { messages.addAll(objectMessages.messages); for (final Map.Entry<RpslAttribute, Messages> entry : objectMessages.attributeMessages.entrySet()) { getMessages(entry.getKey()).addAll(entry.getValue()); } } } | ObjectMessages { public void addAll(final ObjectMessages objectMessages) { messages.addAll(objectMessages.messages); for (final Map.Entry<RpslAttribute, Messages> entry : objectMessages.attributeMessages.entrySet()) { getMessages(entry.getKey()).addAll(entry.getValue()); } } Messages getMessages(); Map<RpslAttribute, Messages> getAttributeMessages(); boolean contains(final Message message); void addMessage(final Message message); void addMessage(final RpslAttribute attribute, final Message message); Messages getMessages(final RpslAttribute attribute); boolean hasErrors(); boolean hasMessages(); int getErrorCount(); void addAll(final ObjectMessages objectMessages); @Override String toString(); } | ObjectMessages { public void addAll(final ObjectMessages objectMessages) { messages.addAll(objectMessages.messages); for (final Map.Entry<RpslAttribute, Messages> entry : objectMessages.attributeMessages.entrySet()) { getMessages(entry.getKey()).addAll(entry.getValue()); } } Messages getMessages(); Map<RpslAttribute, Messages> getAttributeMessages(); boolean contains(final Message message); void addMessage(final Message message); void addMessage(final RpslAttribute attribute, final Message message); Messages getMessages(final RpslAttribute attribute); boolean hasErrors(); boolean hasMessages(); int getErrorCount(); void addAll(final ObjectMessages objectMessages); @Override String toString(); } |
@Test public void handle_object_create() throws IOException { when(grsSource.getName()).thenReturn(ciString("APNIC-GRS")); when(authoritativeResource.isMaintainedInRirSpace(any(RpslObject.class))).thenReturn(true); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { final ObjectHandler objectHandler = (ObjectHandler) invocationOnMock.getArguments()[1]; objectHandler.handle(RpslObject.parse("" + "aut-num: AS1263\n" + "as-name: NSN-TEST-AS\n" + "descr: NSN-TEST-AS\n" + "admin-c: Not available\n" + "tech-c: See MAINT-AS1263\n" + "mnt-by: MAINT-AS1263\n" + "changed: [email protected] 19950201\n" + "source: RIPE" )); return null; } }).when(grsSource).handleObjects(any(File.class), any(ObjectHandler.class)); subject.grsImport(grsSource, false); verify(grsDao).createObject(RpslObject.parse("" + "aut-num: AS1263\n" + "as-name: NSN-TEST-AS\n" + "descr: NSN-TEST-AS\n" + "admin-c: Not available\n" + "tech-c: See MAINT-AS1263\n" + "mnt-by: MAINT-AS1263\n" + "source: APNIC-GRS")); verify(sanitizer).sanitize(any(RpslObject.class), any(ObjectMessages.class)); } | void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } |
@Test public void test_run_no_temporary_blocks() throws Exception { when(accessControlListDao.getTemporaryBlocks(now)).thenReturn(Collections.<BlockEvents>emptyList()); subject.run(); verify(accessControlListDao, never()).savePermanentBlock(any(IpInterval.class), any(LocalDate.class), anyInt(), anyString()); } | @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "AutomaticPermanentBlocks") public void run() { final LocalDate now = dateTimeProvider.getCurrentDate(); final LocalDate checkTemporaryBlockTime = now.minusDays(30); final List<BlockEvents> temporaryBlocks = accessControlListDao.getTemporaryBlocks(checkTemporaryBlockTime); for (final BlockEvents blockEvents : temporaryBlocks) { handleBlockEvents(now, blockEvents); } } | AutomaticPermanentBlocks implements DailyScheduledTask { @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "AutomaticPermanentBlocks") public void run() { final LocalDate now = dateTimeProvider.getCurrentDate(); final LocalDate checkTemporaryBlockTime = now.minusDays(30); final List<BlockEvents> temporaryBlocks = accessControlListDao.getTemporaryBlocks(checkTemporaryBlockTime); for (final BlockEvents blockEvents : temporaryBlocks) { handleBlockEvents(now, blockEvents); } } } | AutomaticPermanentBlocks implements DailyScheduledTask { @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "AutomaticPermanentBlocks") public void run() { final LocalDate now = dateTimeProvider.getCurrentDate(); final LocalDate checkTemporaryBlockTime = now.minusDays(30); final List<BlockEvents> temporaryBlocks = accessControlListDao.getTemporaryBlocks(checkTemporaryBlockTime); for (final BlockEvents blockEvents : temporaryBlocks) { handleBlockEvents(now, blockEvents); } } @Autowired AutomaticPermanentBlocks(final DateTimeProvider dateTimeProvider,
final AccessControlListDao accessControlListDao,
final IpResourceConfiguration ipResourceConfiguration); } | AutomaticPermanentBlocks implements DailyScheduledTask { @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "AutomaticPermanentBlocks") public void run() { final LocalDate now = dateTimeProvider.getCurrentDate(); final LocalDate checkTemporaryBlockTime = now.minusDays(30); final List<BlockEvents> temporaryBlocks = accessControlListDao.getTemporaryBlocks(checkTemporaryBlockTime); for (final BlockEvents blockEvents : temporaryBlocks) { handleBlockEvents(now, blockEvents); } } @Autowired AutomaticPermanentBlocks(final DateTimeProvider dateTimeProvider,
final AccessControlListDao accessControlListDao,
final IpResourceConfiguration ipResourceConfiguration); @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "AutomaticPermanentBlocks") void run(); } | AutomaticPermanentBlocks implements DailyScheduledTask { @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "AutomaticPermanentBlocks") public void run() { final LocalDate now = dateTimeProvider.getCurrentDate(); final LocalDate checkTemporaryBlockTime = now.minusDays(30); final List<BlockEvents> temporaryBlocks = accessControlListDao.getTemporaryBlocks(checkTemporaryBlockTime); for (final BlockEvents blockEvents : temporaryBlocks) { handleBlockEvents(now, blockEvents); } } @Autowired AutomaticPermanentBlocks(final DateTimeProvider dateTimeProvider,
final AccessControlListDao accessControlListDao,
final IpResourceConfiguration ipResourceConfiguration); @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "AutomaticPermanentBlocks") void run(); } |
@Test(expected = IllegalStateException.class) public void getObjectSpec_null() { ObjectTemplate.getTemplate(null); } | public static ObjectTemplate getTemplate(final ObjectType type) { final ObjectTemplate objectTemplate = TEMPLATE_MAP.get(type); if (objectTemplate == null) { throw new IllegalStateException("No template for " + type); } return objectTemplate; } | ObjectTemplate implements Comparable<ObjectTemplate> { public static ObjectTemplate getTemplate(final ObjectType type) { final ObjectTemplate objectTemplate = TEMPLATE_MAP.get(type); if (objectTemplate == null) { throw new IllegalStateException("No template for " + type); } return objectTemplate; } } | ObjectTemplate implements Comparable<ObjectTemplate> { public static ObjectTemplate getTemplate(final ObjectType type) { final ObjectTemplate objectTemplate = TEMPLATE_MAP.get(type); if (objectTemplate == null) { throw new IllegalStateException("No template for " + type); } return objectTemplate; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); } | ObjectTemplate implements Comparable<ObjectTemplate> { public static ObjectTemplate getTemplate(final ObjectType type) { final ObjectTemplate objectTemplate = TEMPLATE_MAP.get(type); if (objectTemplate == null) { throw new IllegalStateException("No template for " + type); } return objectTemplate; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } | ObjectTemplate implements Comparable<ObjectTemplate> { public static ObjectTemplate getTemplate(final ObjectType type) { final ObjectTemplate objectTemplate = TEMPLATE_MAP.get(type); if (objectTemplate == null) { throw new IllegalStateException("No template for " + type); } return objectTemplate; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } |
@Test public void getObjectType() { assertThat(subject.getObjectType(), is(ObjectType.MNTNER)); } | public ObjectType getObjectType() { return objectType; } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectType getObjectType() { return objectType; } } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectType getObjectType() { return objectType; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectType getObjectType() { return objectType; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectType getObjectType() { return objectType; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } |
@Test public void validate_no_errors() { final ObjectMessages objectMessages = subject.validate(RpslObject.parse(MAINTAINER_OBJECT_STRING)); assertThat(objectMessages.hasErrors(), is(false)); } | public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } |
@Test public void getMultipleAttributes(){ final ObjectTemplate template = ObjectTemplate.getTemplate(ObjectType.AS_BLOCK); Set<AttributeType> multipleAttributes = template.getMultipleAttributes(); assertThat(multipleAttributes.size(), is(6)); } | public Set<AttributeType> getMultipleAttributes() { return multipleAttributes; } | ObjectTemplate implements Comparable<ObjectTemplate> { public Set<AttributeType> getMultipleAttributes() { return multipleAttributes; } } | ObjectTemplate implements Comparable<ObjectTemplate> { public Set<AttributeType> getMultipleAttributes() { return multipleAttributes; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); } | ObjectTemplate implements Comparable<ObjectTemplate> { public Set<AttributeType> getMultipleAttributes() { return multipleAttributes; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } | ObjectTemplate implements Comparable<ObjectTemplate> { public Set<AttributeType> getMultipleAttributes() { return multipleAttributes; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } |
@Test public void validate_mandatory_missing() { final RpslObject rpslObject = RpslObject.parse(MAINTAINER_OBJECT_STRING.substring(0, MAINTAINER_OBJECT_STRING.lastIndexOf('\n') + 1)); final ObjectMessages objectMessages = subject.validate(rpslObject); assertThat(objectMessages.hasErrors(), is(true)); assertThat(objectMessages.getMessages().getErrors(), contains(ValidationMessages.missingMandatoryAttribute(AttributeType.SOURCE))); assertZeroAttributeErrors(rpslObject, objectMessages); } | public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } |
@Test public void validate_single_occurs_multiple_times() { final RpslObject rpslObject = RpslObject.parse(MAINTAINER_OBJECT_STRING + "\nsource: RIPE\n"); final ObjectMessages objectMessages = subject.validate(rpslObject); assertThat(objectMessages.hasErrors(), is(true)); assertThat(objectMessages.getMessages().getErrors(), contains(ValidationMessages.tooManyAttributesOfType(AttributeType.SOURCE))); assertZeroAttributeErrors(rpslObject, objectMessages); } | public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } | ObjectTemplate implements Comparable<ObjectTemplate> { public ObjectMessages validate(final RpslObject rpslObject) { final ObjectMessages objectMessages = new ObjectMessages(); validateStructure(rpslObject, objectMessages); validateSyntax(rpslObject, objectMessages, false); return objectMessages; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } |
@Test public void isSet() { for (ObjectType objectType : ObjectType.values()) { assertThat(objectType.getName().toLowerCase().contains("set"), is(ObjectTemplate.getTemplate(objectType).isSet())); } } | public boolean isSet() { return ObjectType.getSets().contains(objectType); } | ObjectTemplate implements Comparable<ObjectTemplate> { public boolean isSet() { return ObjectType.getSets().contains(objectType); } } | ObjectTemplate implements Comparable<ObjectTemplate> { public boolean isSet() { return ObjectType.getSets().contains(objectType); } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); } | ObjectTemplate implements Comparable<ObjectTemplate> { public boolean isSet() { return ObjectType.getSets().contains(objectType); } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } | ObjectTemplate implements Comparable<ObjectTemplate> { public boolean isSet() { return ObjectType.getSets().contains(objectType); } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } |
@Test public void allObjectTypesSupported() { for (final ObjectType objectType : ObjectType.values()) { ObjectTemplate.getTemplate(objectType); } } | public static ObjectTemplate getTemplate(final ObjectType type) { final ObjectTemplate objectTemplate = TEMPLATE_MAP.get(type); if (objectTemplate == null) { throw new IllegalStateException("No template for " + type); } return objectTemplate; } | ObjectTemplate implements Comparable<ObjectTemplate> { public static ObjectTemplate getTemplate(final ObjectType type) { final ObjectTemplate objectTemplate = TEMPLATE_MAP.get(type); if (objectTemplate == null) { throw new IllegalStateException("No template for " + type); } return objectTemplate; } } | ObjectTemplate implements Comparable<ObjectTemplate> { public static ObjectTemplate getTemplate(final ObjectType type) { final ObjectTemplate objectTemplate = TEMPLATE_MAP.get(type); if (objectTemplate == null) { throw new IllegalStateException("No template for " + type); } return objectTemplate; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); } | ObjectTemplate implements Comparable<ObjectTemplate> { public static ObjectTemplate getTemplate(final ObjectType type) { final ObjectTemplate objectTemplate = TEMPLATE_MAP.get(type); if (objectTemplate == null) { throw new IllegalStateException("No template for " + type); } return objectTemplate; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } | ObjectTemplate implements Comparable<ObjectTemplate> { public static ObjectTemplate getTemplate(final ObjectType type) { final ObjectTemplate objectTemplate = TEMPLATE_MAP.get(type); if (objectTemplate == null) { throw new IllegalStateException("No template for " + type); } return objectTemplate; } private ObjectTemplate(final ObjectType objectType, final int orderPosition, final AttributeTemplate... attributeTemplates); static ObjectTemplate getTemplate(final ObjectType type); static Collection<ObjectTemplate> getTemplates(); ObjectType getObjectType(); List<AttributeTemplate> getAttributeTemplates(); Set<AttributeType> getAllAttributes(); Set<AttributeType> getKeyAttributes(); Set<AttributeType> getLookupAttributes(); AttributeType getKeyLookupAttribute(); Set<AttributeType> getMandatoryAttributes(); Set<AttributeType> getInverseLookupAttributes(); Set<AttributeType> getGeneratedAttributes(); Set<AttributeType> getMultipleAttributes(); Comparator<RpslAttribute> getAttributeTypeComparator(); boolean isSet(); String getNameToFirstUpper( ); String getNameToFirstLower( ); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(@Nonnull final ObjectTemplate o); void validateStructure(final RpslObject rpslObject, final ObjectMessages objectMessages); void validateSyntax(final RpslObject rpslObject, final ObjectMessages objectMessages, final boolean skipGenerated); ObjectMessages validate(final RpslObject rpslObject); @Override String toString(); String toVerboseString(); boolean hasAttribute(final AttributeType attributeType); } |
@Test(expected = IllegalArgumentException.class) public void parseNullFails() { RpslObject.parse((byte[]) null); } | public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test(expected = IllegalArgumentException.class) public void parseEmptyFails() { RpslObject.parse(new byte[]{}); } | public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void handle_object_create_syntax_errors() throws IOException { when(grsSource.getName()).thenReturn(ciString("APNIC-GRS")); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { final ObjectHandler objectHandler = (ObjectHandler) invocationOnMock.getArguments()[1]; objectHandler.handle(RpslObject.parse("" + "mntner: SOME\n" + "changed: [email protected] 19950201\n" + "unknown: unknown" + "source: RIPE" )); return null; } }).when(grsSource).handleObjects(any(File.class), any(ObjectHandler.class)); subject.grsImport(grsSource, false); verify(grsDao, never()).createObject(any(RpslObject.class)); verify(sanitizer).sanitize(any(RpslObject.class), any(ObjectMessages.class)); } | void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } |
@Test public void checkThatSpecialCharactersGetThrough() { parseAndAssign("person: New Test Person\n" + "address: Flughafenstraße 120\n" + "address: D - 40474 Düsseldorf\n" + "nic-hdl: ABC-RIPE\n"); assertThat(subject.toString(), containsString("Flughafenstraße")); assertThat(subject.toString(), containsString("Düsseldorf")); } | @Override public String toString() { try { final StringWriter writer = new StringWriter(); for (final RpslAttribute attribute : getAttributes()) { attribute.writeTo(writer); } return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } | RpslObject implements Identifiable, ResponseObject { @Override public String toString() { try { final StringWriter writer = new StringWriter(); for (final RpslAttribute attribute : getAttributes()) { attribute.writeTo(writer); } return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } } | RpslObject implements Identifiable, ResponseObject { @Override public String toString() { try { final StringWriter writer = new StringWriter(); for (final RpslAttribute attribute : getAttributes()) { attribute.writeTo(writer); } return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { @Override public String toString() { try { final StringWriter writer = new StringWriter(); for (final RpslAttribute attribute : getAttributes()) { attribute.writeTo(writer); } return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { @Override public String toString() { try { final StringWriter writer = new StringWriter(); for (final RpslAttribute attribute : getAttributes()) { attribute.writeTo(writer); } return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void checkThatUtf8CharactersGetThroughAndConverted() { parseAndAssign("person: New Test Person\n" + "address: Flughafenstraße 120/Σ\n" + "address: D - 40474 Düsseldorf\n" + "nic-hdl: ABC-RIPE\n"); List<RpslAttribute> addresses = subject.findAttributes(AttributeType.ADDRESS); assertThat(addresses, hasSize(2)); assertThat(addresses.get(0).getValue(), containsString("Flughafenstraße 120/?")); assertThat(addresses.get(1).getValue(), containsString("Düsseldorf")); } | public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void checkThatUtf8CharactersGetConverted() { parseAndAssign("person: New Test Person\n" + "address: Тверская улица,москва\n" + "nic-hdl: ABC-RIPE\n"); List<RpslAttribute> addresses = subject.findAttributes(AttributeType.ADDRESS); assertThat(addresses, hasSize(1)); assertThat(addresses.get(0).getValue(), containsString("???????? ?????,??????")); } | public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void parseMultipleIdenticalKeys() { String key = "descr"; int amount = 1000; parseAndAssign("mntner: DEV-MNT\n" + StringUtils.repeat(key + ": value", "\n", amount)); assertThat(subject.findAttributes(AttributeType.DESCR), hasSize(amount)); } | public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void findAttributes_multiple() { parseAndAssign(maintainer); assertThat(subject.findAttributes(AttributeType.MNTNER, AttributeType.ADMIN_C, AttributeType.TECH_C), hasSize(3)); } | public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public List<RpslAttribute> findAttributes(final AttributeType attributeType) { final List<RpslAttribute> list = getOrCreateCache().get(attributeType); return list == null ? Collections.<RpslAttribute>emptyList() : Collections.unmodifiableList(list); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test(expected = IllegalArgumentException.class) public void test_get_key_person_empty() { parseAndAssign("person: foo # Comment \n"); subject.getKey(); } | public final CIString getKey() { return key; } | RpslObject implements Identifiable, ResponseObject { public final CIString getKey() { return key; } } | RpslObject implements Identifiable, ResponseObject { public final CIString getKey() { return key; } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public final CIString getKey() { return key; } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public final CIString getKey() { return key; } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void containsAttribute_works() { parseAndAssign(maintainer); assertThat(subject.containsAttribute(AttributeType.SOURCE), is(true)); } | public boolean containsAttribute(final AttributeType attributeType) { return getOrCreateCache().containsKey(attributeType); } | RpslObject implements Identifiable, ResponseObject { public boolean containsAttribute(final AttributeType attributeType) { return getOrCreateCache().containsKey(attributeType); } } | RpslObject implements Identifiable, ResponseObject { public boolean containsAttribute(final AttributeType attributeType) { return getOrCreateCache().containsKey(attributeType); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public boolean containsAttribute(final AttributeType attributeType) { return getOrCreateCache().containsKey(attributeType); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public boolean containsAttribute(final AttributeType attributeType) { return getOrCreateCache().containsKey(attributeType); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void containsAttribute_unknown() { parseAndAssign(maintainer); assertThat(subject.containsAttribute(AttributeType.PERSON), is(false)); } | public boolean containsAttribute(final AttributeType attributeType) { return getOrCreateCache().containsKey(attributeType); } | RpslObject implements Identifiable, ResponseObject { public boolean containsAttribute(final AttributeType attributeType) { return getOrCreateCache().containsKey(attributeType); } } | RpslObject implements Identifiable, ResponseObject { public boolean containsAttribute(final AttributeType attributeType) { return getOrCreateCache().containsKey(attributeType); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public boolean containsAttribute(final AttributeType attributeType) { return getOrCreateCache().containsKey(attributeType); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public boolean containsAttribute(final AttributeType attributeType) { return getOrCreateCache().containsKey(attributeType); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void tab_continuation_equivalent_to_space_continuation() { assertThat(RpslObject.parse("mntner: mnt\n a"), is(RpslObject.parse("mntner: mnt\n\ta"))); } | public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void compareRpslObjects_single() { assertThat(RpslObject.parse("mntner: mnt"), is(RpslObject.parse("mntner: mnt"))); assertThat(RpslObject.parse("mntner: mnt"), is(RpslObject.parse("mntner: mnt\n"))); assertThat(RpslObject.parse("mntner: mnt"), is(not(RpslObject.parse("mntner: mnt\n\ta")))); assertThat(RpslObject.parse("mntner: mnt\n a"), is(RpslObject.parse("mntner: mnt\n\ta"))); assertThat(RpslObject.parse("mntner: mnt\n \t\t a"), is(RpslObject.parse("mntner: mnt\n\ta"))); assertThat(RpslObject.parse("mntner: \t mnt \t \n \t a"), is(RpslObject.parse("mntner: mnt\n\ta"))); assertThat(RpslObject.parse("mntner: \t one \t two \t \n \t a"), is(RpslObject.parse("mntner: one two\n\ta"))); assertThat(RpslObject.parse("mntner:one \t two \t \n \t a"), is(RpslObject.parse("mntner: one two\n\ta"))); assertThat(RpslObject.parse("mntner: mnt # comment"), is(RpslObject.parse("mntner: mnt"))); assertThat(RpslObject.parse("mntner: mnt # comment"), is(RpslObject.parse("mntner: mnt # comment"))); assertThat(RpslObject.parse("mntner: mnt# comment"), is(RpslObject.parse("mntner: mnt # comment"))); assertThat(RpslObject.parse("mntner: mnt # com ment"), is(RpslObject.parse("mntner: mnt # com ment"))); assertThat(RpslObject.parse("mntner: mnt # com ment"), is(RpslObject.parse("mntner: mnt #com ment"))); assertThat(RpslObject.parse("mntner: mnt two three four"), is(RpslObject.parse("mntner: mnt # one\n two\n+ three\n\tfour"))); } | public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void handle_lines_create_with_unknown_attribute() throws IOException { when(grsSource.getName()).thenReturn(ciString("APNIC-GRS")); when(authoritativeResource.isMaintainedInRirSpace(any(RpslObject.class))).thenReturn(true); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { final ObjectHandler objectHandler = (ObjectHandler) invocationOnMock.getArguments()[1]; objectHandler.handle(Lists.newArrayList( "aut-num: AS1263\n", "as-name: NSN-TEST-AS\n", "descr: NSN-TEST-AS\n", " NSN-TEST-AS\n", "admin-c: Not available\n", "unknown: oops\n", "tech-c: See MAINT-AS1263\n", "mnt-by: MAINT-AS1263\n", "changed: [email protected] 19950201\n", "source: RIPE\n" )); return null; } }).when(grsSource).handleObjects(any(File.class), any(ObjectHandler.class)); subject.grsImport(grsSource, false); verify(grsDao).createObject(RpslObject.parse("" + "aut-num: AS1263\n" + "as-name: NSN-TEST-AS\n" + "descr: NSN-TEST-AS\n" + " NSN-TEST-AS\n" + "admin-c: Not available\n" + "tech-c: See MAINT-AS1263\n" + "mnt-by: MAINT-AS1263\n" + "source: APNIC-GRS")); verify(sanitizer).sanitize(any(RpslObject.class), any(ObjectMessages.class)); } | void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } |
@Test public void compareRpslObjects_multiple() { assertThat(RpslObject.parse("mntner: mnt\nsource: RIPE"), is(RpslObject.parse("mntner: mnt\nsource: RIPE\n"))); assertThat(RpslObject.parse("mntner: mnt\nsource: RIPE"), is(RpslObject.parse("mntner: mnt\nsource:\tRIPE\n"))); assertThat(RpslObject.parse("mntner: mnt\n+one\nsource: RIPE"), is(RpslObject.parse("mntner: mnt\n\tone\nsource:\tRIPE\n"))); assertThat(RpslObject.parse("mntner: mnt\n+#one\nsource: RIPE"), is(RpslObject.parse("mntner: mnt\n\t #two\nsource:\tRIPE\n"))); } | public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void getValueForAttribute() { assertThat(RpslObject.parse("mntner: DEV-MNT\n").getValueForAttribute(AttributeType.MNTNER).toString(), is("DEV-MNT")); } | public CIString getValueForAttribute(final AttributeType attributeType) { return findAttribute(attributeType).getCleanValue(); } | RpslObject implements Identifiable, ResponseObject { public CIString getValueForAttribute(final AttributeType attributeType) { return findAttribute(attributeType).getCleanValue(); } } | RpslObject implements Identifiable, ResponseObject { public CIString getValueForAttribute(final AttributeType attributeType) { return findAttribute(attributeType).getCleanValue(); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public CIString getValueForAttribute(final AttributeType attributeType) { return findAttribute(attributeType).getCleanValue(); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public CIString getValueForAttribute(final AttributeType attributeType) { return findAttribute(attributeType).getCleanValue(); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void getValuesForAttribute() { final RpslObject object = RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-by: DEV-MNT5\n" + "mnt-by: DEV-MNT4, DEV-MNT4\n" + "mnt-by: DEV-MNT3, DEV-MNT2\n" + "mnt-by: DEV-MNT1, DEV-MNT2\n"); assertThat(convertToString(object.getValuesForAttribute(AttributeType.MNT_BY)), contains("DEV-MNT5", "DEV-MNT4", "DEV-MNT3", "DEV-MNT2", "DEV-MNT1")); assertThat(object.getValuesForAttribute(AttributeType.ADMIN_C), hasSize(0)); } | public Set<CIString> getValuesForAttribute(final AttributeType... attributeType) { final Set<CIString> values = Sets.newLinkedHashSet(); for (AttributeType attrType : attributeType) { final List<RpslAttribute> rpslAttributes = getOrCreateCache().get(attrType); if (rpslAttributes != null && !rpslAttributes.isEmpty()) { for (RpslAttribute rpslAttribute : rpslAttributes) { values.addAll(rpslAttribute.getCleanValues()); } } } return values; } | RpslObject implements Identifiable, ResponseObject { public Set<CIString> getValuesForAttribute(final AttributeType... attributeType) { final Set<CIString> values = Sets.newLinkedHashSet(); for (AttributeType attrType : attributeType) { final List<RpslAttribute> rpslAttributes = getOrCreateCache().get(attrType); if (rpslAttributes != null && !rpslAttributes.isEmpty()) { for (RpslAttribute rpslAttribute : rpslAttributes) { values.addAll(rpslAttribute.getCleanValues()); } } } return values; } } | RpslObject implements Identifiable, ResponseObject { public Set<CIString> getValuesForAttribute(final AttributeType... attributeType) { final Set<CIString> values = Sets.newLinkedHashSet(); for (AttributeType attrType : attributeType) { final List<RpslAttribute> rpslAttributes = getOrCreateCache().get(attrType); if (rpslAttributes != null && !rpslAttributes.isEmpty()) { for (RpslAttribute rpslAttribute : rpslAttributes) { values.addAll(rpslAttribute.getCleanValues()); } } } return values; } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public Set<CIString> getValuesForAttribute(final AttributeType... attributeType) { final Set<CIString> values = Sets.newLinkedHashSet(); for (AttributeType attrType : attributeType) { final List<RpslAttribute> rpslAttributes = getOrCreateCache().get(attrType); if (rpslAttributes != null && !rpslAttributes.isEmpty()) { for (RpslAttribute rpslAttribute : rpslAttributes) { values.addAll(rpslAttribute.getCleanValues()); } } } return values; } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public Set<CIString> getValuesForAttribute(final AttributeType... attributeType) { final Set<CIString> values = Sets.newLinkedHashSet(); for (AttributeType attrType : attributeType) { final List<RpslAttribute> rpslAttributes = getOrCreateCache().get(attrType); if (rpslAttributes != null && !rpslAttributes.isEmpty()) { for (RpslAttribute rpslAttribute : rpslAttributes) { values.addAll(rpslAttribute.getCleanValues()); } } } return values; } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void cleanvalue_comparator_different_order() { final RpslObject object1 = RpslObject.parse("mntner: DEV-MNT\nmnt-by:DEV-MNT1,DEV-MNT2,DEV-MNT3"); final RpslObject object2 = RpslObject.parse("mntner: DEV-MNT\nmnt-by:DEV-MNT3,DEV-MNT1,DEV-MNT2"); assertThat(object1, not(is(object2))); } | public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void cleanvalue_comparator_different_values() { final RpslObject object1 = RpslObject.parse("mntner: DEV-MNT\nmnt-by:DEV-MNT1,DEV-MNT2,DEV-MNT3"); final RpslObject object2 = RpslObject.parse("mntner: DEV-MNT\nmnt-by:DEV-MNT1,DEV-MNT2,DEV-MNT4"); assertThat(object1, not(is(object2))); } | public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void cleanvalue_comparator_same_order() { final RpslObject object1 = RpslObject.parse("mntner: DEV-MNT\nmnt-by:DEV-MNT1,DEV-MNT2,DEV-MNT3"); final RpslObject object2 = RpslObject.parse("mntner: DEV-MNT\nmnt-by:DEV-MNT1,DEV-MNT2,DEV-MNT3"); assertThat(object1, is(object2)); } | public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void cleanvalue_comparator_same_order_different_casing() { final RpslObject object1 = RpslObject.parse("mntner: DEV-MNT\nmnt-by:DEV-MNT1,DEV-MNT2,DEV-MNT3"); final RpslObject object2 = RpslObject.parse("MNTNER: dev-mnt\nmnt-by:DEV-MNT1,DEV-MNT2,DEV-MNT3"); assertThat(object1, is(object2)); } | public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void cleanvalue_comparator_same_order_different_key() { final RpslObject object1 = RpslObject.parse("mntner: DEV-MNT\nmnt-by:DEV-MNT1,DEV-MNT2,DEV-MNT3"); final RpslObject object2 = RpslObject.parse("poem: dev-mnt\nmnt-by:DEV-MNT1,DEV-MNT2,DEV-MNT3"); assertThat(object1, not(is(object2))); } | public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void cleanvalue_comparator_different_order_same_attributes() { final RpslObject object1 = RpslObject.parse("mntner: DEV-MNT\nmnt-by:DEV-MNT1\nnic-hdl:NIC-RIPE\nmnt-by:DEV-MNT2,DEV-MNT3"); final RpslObject object2 = RpslObject.parse("mntner: DEV-MNT\nnic-hdl:NIC-RIPE\nmnt-by:DEV-MNT1,DEV-MNT2,DEV-MNT3"); assertThat(object1, not(is(object2))); } | public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void cleanvalue_comparator_subset() { final RpslObject object1 = RpslObject.parse("mntner: DEV-MNT\nmnt-by:DEV-MNT1,DEV-MNT2,DEV-MNT3"); final RpslObject object2 = RpslObject.parse("mntner: DEV-MNT\nmnt-by:DEV-MNT1,DEV-MNT3"); assertThat(object1, not(is(object2))); } | public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void handle_lines_no_source_managed_by_rir() throws IOException { when(grsSource.getName()).thenReturn(ciString("APNIC-GRS")); when(authoritativeResource.isMaintainedInRirSpace(any(RpslObject.class))).thenReturn(true); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { final ObjectHandler objectHandler = (ObjectHandler) invocationOnMock.getArguments()[1]; objectHandler.handle(Lists.newArrayList( "aut-num: AS1263\n", "changed: [email protected] 19950201\n" )); return null; } }).when(grsSource).handleObjects(any(File.class), any(ObjectHandler.class)); subject.grsImport(grsSource, false); verify(grsDao).createObject(RpslObject.parse("" + "aut-num: AS1263\n" + "source: APNIC-GRS")); verify(sanitizer).sanitize(any(RpslObject.class), any(ObjectMessages.class)); } | void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } |
@Test public void multiple_newlines_is_reserved_as_object_separator() { try { RpslObject.parse("mntner: AA1-MNT\n\n"); fail(); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("Read illegal character in key: '\n'")); } } | public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } | RpslObject implements Identifiable, ResponseObject { public static RpslObject parse(final String input) { return new RpslObject(RpslObjectBuilder.getAttributes(input)); } RpslObject(final RpslObject oldObject, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final List<RpslAttribute> attributes); RpslObject(final Integer objectId, final RpslObject rpslObject); RpslObject(final List<RpslAttribute> attributes); static RpslObject parse(final String input); static RpslObject parse(final byte[] input); static RpslObject parse(final Integer objectId, final String input); static RpslObject parse(final Integer objectId, final byte[] input); @Override int getObjectId(); ObjectType getType(); List<RpslAttribute> getAttributes(); int size(); final CIString getKey(); String getFormattedKey(); @Override boolean equals(final Object obj); @Override int hashCode(); RpslAttribute getTypeAttribute(); RpslAttribute findAttribute(final AttributeType attributeType); List<RpslAttribute> findAttributes(final AttributeType attributeType); List<RpslAttribute> findAttributes(final Iterable<AttributeType> attributeTypes); List<RpslAttribute> findAttributes(final AttributeType... attributeTypes); boolean containsAttributes(final Collection<AttributeType> attributeTypes); boolean containsAttribute(final AttributeType attributeType); @Override void writeTo(final OutputStream out); void writeTo(final Writer writer); @Override byte[] toByteArray(); @Override String toString(); CIString getValueForAttribute(final AttributeType attributeType); @Nullable CIString getValueOrNullForAttribute(final AttributeType attributeType); Set<CIString> getValuesForAttribute(final AttributeType... attributeType); } |
@Test public void short_hand_plain() { subject = new RpslAttribute("domain", "foobar"); assertThat(RpslAttributeFilter.getValueForShortHand(subject.getValue()), is(" foobar")); } | public String getValue() { return value; } | RpslAttribute { public String getValue() { return value; } } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void short_hand_spaced_prefix() { subject = new RpslAttribute("domain", " foobar"); assertThat(RpslAttributeFilter.getValueForShortHand(subject.getValue()), is(" foobar")); } | public String getValue() { return value; } | RpslAttribute { public String getValue() { return value; } } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void short_hand_any_continuation() { subject = new RpslAttribute("domain", "foo\n bar\n+qux\n\tzot"); assertThat(RpslAttributeFilter.getValueForShortHand(subject.getValue()), is(" foo\n+ bar\n+ qux\n+ zot")); } | public String getValue() { return value; } | RpslAttribute { public String getValue() { return value; } } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void short_hand_only_touches_continuation_whitespace() { subject = new RpslAttribute("domain", "foo\t # \t\n bar\n+ qux\n\tzot"); assertThat(RpslAttributeFilter.getValueForShortHand(subject.getValue()), is(" foo\t # \t\n+ bar\n+ qux\n+ zot")); } | public String getValue() { return value; } | RpslAttribute { public String getValue() { return value; } } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void short_hand_continuation_spaces() { subject = new RpslAttribute("domain", "foo\n bar\n+ qux\n\t zot"); assertThat(RpslAttributeFilter.getValueForShortHand(subject.getValue()), is(" foo\n+ bar\n+ qux\n+ zot")); } | public String getValue() { return value; } | RpslAttribute { public String getValue() { return value; } } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { public String getValue() { return value; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void equals_is_case_insensitive() { subject = new RpslAttribute("remarks", "The quick brown fox."); assertThat(subject.equals(new RpslAttribute("remarks", "THE QUICK BROWN FOX.")), is(true)); } | @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void equals_unknown_type() { subject = new RpslAttribute("unknown", "The quick brown fox."); assertThat(subject.equals(new RpslAttribute("unknown", "THE QUICK BROWN FOX.")), is(true)); } | @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void equals_Integer() { subject = new RpslAttribute("remarks", "The quick brown fox."); assertFalse(subject.equals(1)); } | @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void equals_null() { subject = new RpslAttribute("remarks", "The quick brown fox."); assertThat(subject, not(is(nullValue()))); assertFalse(subject.equals(null)); } | @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void try_inserting_role_and_person_with_same_nichdl() throws Exception { when(grsSource.getName()).thenReturn(ciString("APNIC-GRS")); when(authoritativeResource.isMaintainedInRirSpace(any(RpslObject.class))).thenReturn(true); doAnswer(new Answer() { @Override public Object answer(final InvocationOnMock invocation) throws Throwable { final ObjectHandler objectHandler = (ObjectHandler) invocation.getArguments()[1]; objectHandler.handle(RpslObject.parse("" + "person: Ninja Person\n" + "nic-hdl: NI124-RIPE\n")); return null; } }).when(grsSource).handleObjects(any(File.class), any(ObjectHandler.class)); final GrsObjectInfo grsObjectInfo1 = new GrsObjectInfo(1, 1, RpslObject.parse("role: Ninja Role\nnic-hdl: NI124-RIPE\n")); when(grsDao.find("NI124-RIPE", ObjectType.PERSON)).thenReturn(null); when(grsDao.find("NI124-RIPE", ObjectType.ROLE)).thenReturn(grsObjectInfo1); subject.grsImport(grsSource, false); verify(grsDao, times(0)).createObject(any(RpslObject.class)); verify(grsDao, times(0)).updateObject(any(GrsObjectInfo.class), any(RpslObject.class)); } | void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } |
@Test public void equals_shorthand() { subject = new RpslAttribute("remarks", "The quick brown fox."); assertThat(subject.equals(new RpslAttribute("*rm", "THE QUICK BROWN FOX.")), is(true)); } | @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } final RpslAttribute attribute = (RpslAttribute) o; if (type == null) { if (attribute.type != null) { return false; } return key.equals(attribute.key); } else { if (type != attribute.type) { return false; } return Iterables.elementsEqual(getCleanValues(), attribute.getCleanValues()); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void validateSyntax_syntax_error_and_invalid_email() { final ObjectMessages objectMessages = new ObjectMessages(); final RpslAttribute rpslAttribute = new RpslAttribute("inetnum", "[email protected]"); rpslAttribute.validateSyntax(ObjectType.INETNUM, objectMessages); assertThat(objectMessages.getMessages(rpslAttribute).getAllMessages(), contains(ValidationMessages.syntaxError("[email protected]"))); } | public void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages) { for (final CIString cleanValue : getCleanValues()) { if (!type.getSyntax().matches(objectType, cleanValue.toString())) { objectMessages.addMessage(this, ValidationMessages.syntaxError(cleanValue.toString())); } } } | RpslAttribute { public void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages) { for (final CIString cleanValue : getCleanValues()) { if (!type.getSyntax().matches(objectType, cleanValue.toString())) { objectMessages.addMessage(this, ValidationMessages.syntaxError(cleanValue.toString())); } } } } | RpslAttribute { public void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages) { for (final CIString cleanValue : getCleanValues()) { if (!type.getSyntax().matches(objectType, cleanValue.toString())) { objectMessages.addMessage(this, ValidationMessages.syntaxError(cleanValue.toString())); } } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { public void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages) { for (final CIString cleanValue : getCleanValues()) { if (!type.getSyntax().matches(objectType, cleanValue.toString())) { objectMessages.addMessage(this, ValidationMessages.syntaxError(cleanValue.toString())); } } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { public void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages) { for (final CIString cleanValue : getCleanValues()) { if (!type.getSyntax().matches(objectType, cleanValue.toString())) { objectMessages.addMessage(this, ValidationMessages.syntaxError(cleanValue.toString())); } } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void format_single_line_no_spaces() { final RpslAttribute subject = new RpslAttribute("person", "Brian Riddle"); assertThat(subject.toString(), is("person: Brian Riddle\n")); } | @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } | RpslAttribute { @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } } | RpslAttribute { @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void format_single_line_some_spaces() { final RpslAttribute subject = new RpslAttribute("person", " Brian Riddle"); assertThat(subject.toString(), is("person: Brian Riddle\n")); } | @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } | RpslAttribute { @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } } | RpslAttribute { @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void format_single_line_too_many_spaces() { final RpslAttribute subject = new RpslAttribute("person", " Brian Riddle"); assertThat(subject.toString(), is("person: Brian Riddle\n")); } | @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } | RpslAttribute { @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } } | RpslAttribute { @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { @Override public String toString() { try { final StringWriter writer = new StringWriter(); writeTo(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should never occur", e); } } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void get_comment_in_second_line() { subject = new RpslAttribute("remarks", "remark1\n remark2 # comment"); assertThat(subject.getCleanComment(), is("comment")); subject = new RpslAttribute("remarks", "foo\t # comment1 \n bar # \t comment2\n+ bla"); assertThat(subject.getCleanComment(), is("comment1 comment2")); } | public String getCleanComment() { if (cleanValues == null) { extractCleanValueAndComment(value); } return cleanComment; } | RpslAttribute { public String getCleanComment() { if (cleanValues == null) { extractCleanValueAndComment(value); } return cleanComment; } } | RpslAttribute { public String getCleanComment() { if (cleanValues == null) { extractCleanValueAndComment(value); } return cleanComment; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); } | RpslAttribute { public String getCleanComment() { if (cleanValues == null) { extractCleanValueAndComment(value); } return cleanComment; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } | RpslAttribute { public String getCleanComment() { if (cleanValues == null) { extractCleanValueAndComment(value); } return cleanComment; } RpslAttribute(final AttributeType attributeType, final CIString value); RpslAttribute(final AttributeType attributeType, final String value); RpslAttribute(final String key, final CIString value); RpslAttribute(final String key, final String value); String getKey(); String getValue(); String getCleanComment(); CIString getCleanValue(); Set<CIString> getCleanValues(); Set<CIString> getReferenceValues(); CIString getReferenceValue(); void validateSyntax(final ObjectType objectType, final ObjectMessages objectMessages); void writeTo(final Writer writer); String getFormattedValue(); void writeAttributeValueTo(final Writer writer); @Override boolean equals(Object o); @Override int hashCode(); @CheckForNull AttributeType getType(); @Override String toString(); } |
@Test public void validateMoreSpecificsOperator() { ParserHelper.validateMoreSpecificsOperator("^0"); ParserHelper.validateMoreSpecificsOperator("^32"); } | public static void validateMoreSpecificsOperator(final String yytext) { int val = Integer.valueOf(yytext.substring(1)); if (val > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext.substring(1) + " not 0 to 32 bits"); } } | ParserHelper { public static void validateMoreSpecificsOperator(final String yytext) { int val = Integer.valueOf(yytext.substring(1)); if (val > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext.substring(1) + " not 0 to 32 bits"); } } } | ParserHelper { public static void validateMoreSpecificsOperator(final String yytext) { int val = Integer.valueOf(yytext.substring(1)); if (val > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext.substring(1) + " not 0 to 32 bits"); } } private ParserHelper(); } | ParserHelper { public static void validateMoreSpecificsOperator(final String yytext) { int val = Integer.valueOf(yytext.substring(1)); if (val > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext.substring(1) + " not 0 to 32 bits"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateMoreSpecificsOperator(final String yytext) { int val = Integer.valueOf(yytext.substring(1)); if (val > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext.substring(1) + " not 0 to 32 bits"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateMoreSpecificsOperatorFailsTooLarge() { ParserHelper.validateMoreSpecificsOperator("^33"); } | public static void validateMoreSpecificsOperator(final String yytext) { int val = Integer.valueOf(yytext.substring(1)); if (val > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext.substring(1) + " not 0 to 32 bits"); } } | ParserHelper { public static void validateMoreSpecificsOperator(final String yytext) { int val = Integer.valueOf(yytext.substring(1)); if (val > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext.substring(1) + " not 0 to 32 bits"); } } } | ParserHelper { public static void validateMoreSpecificsOperator(final String yytext) { int val = Integer.valueOf(yytext.substring(1)); if (val > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext.substring(1) + " not 0 to 32 bits"); } } private ParserHelper(); } | ParserHelper { public static void validateMoreSpecificsOperator(final String yytext) { int val = Integer.valueOf(yytext.substring(1)); if (val > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext.substring(1) + " not 0 to 32 bits"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateMoreSpecificsOperator(final String yytext) { int val = Integer.valueOf(yytext.substring(1)); if (val > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext.substring(1) + " not 0 to 32 bits"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test public void validateRangeMoreSpecificsOperators() { ParserHelper.validateRangeMoreSpecificsOperators("^0-0"); ParserHelper.validateRangeMoreSpecificsOperators("^0-1"); ParserHelper.validateRangeMoreSpecificsOperators("^0-32"); ParserHelper.validateRangeMoreSpecificsOperators("^31-32"); } | public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } | ParserHelper { public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } } | ParserHelper { public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } private ParserHelper(); } | ParserHelper { public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateRangeMoreSpecificsOperatorsInverseRange() { ParserHelper.validateRangeMoreSpecificsOperators("^1-0"); } | public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } | ParserHelper { public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } } | ParserHelper { public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } private ParserHelper(); } | ParserHelper { public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test public void run_create_update_delete() throws IOException { when(grsSource.getName()).thenReturn(ciString("APNIC-GRS")); when(grsDao.getCurrentObjectIds()).thenReturn(Lists.newArrayList(1, 2, 3)); when(authoritativeResource.isMaintainedInRirSpace(any(RpslObject.class))).thenReturn(true); doAnswer(new Answer() { @Override public Object answer(final InvocationOnMock invocation) throws Throwable { final ObjectHandler objectHandler = (ObjectHandler) invocation.getArguments()[1]; objectHandler.handle(RpslObject.parse("" + "mntner: MODIFY-MNT\n" + "mnt-by: CREATE-MNT\n")); objectHandler.handle(RpslObject.parse("" + "mntner: CREATE-MNT\n" + "mnt-by: CREATE-MNT\n")); objectHandler.handle(RpslObject.parse("" + "mntner: NOOP-MNT\n")); return null; } }).when(grsSource).handleObjects(any(File.class), any(ObjectHandler.class)); when(updateResultUpdate.hasMissingReferences()).thenReturn(true); final GrsObjectInfo grsObjectInfo1 = new GrsObjectInfo(1, 1, RpslObject.parse("mntner: MODIFY-MNT")); when(grsDao.find("MODIFY-MNT", ObjectType.MNTNER)).thenReturn(grsObjectInfo1); final GrsObjectInfo grsObjectInfo2 = new GrsObjectInfo(2, 2, RpslObject.parse("mntner: NOOP-MNT\nsource: APNIC-GRS")); when(grsDao.find("NOOP-MNT", ObjectType.MNTNER)).thenReturn(grsObjectInfo2); subject.grsImport(grsSource, false); verify(grsDao).createObject(RpslObject.parse("" + "mntner: CREATE-MNT\n" + "mnt-by: CREATE-MNT\n" + "source: APNIC-GRS")); verify(grsDao).updateObject(grsObjectInfo1, RpslObject.parse("" + "mntner: MODIFY-MNT\n" + "mnt-by: CREATE-MNT\n" + "source: APNIC-GRS")); verify(grsDao).updateIndexes(0); verify(grsDao, times(1)).updateObject(any(GrsObjectInfo.class), any(RpslObject.class)); verify(grsDao).deleteObject(3); } | void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } | GrsSourceImporter { void grsImport(final GrsSource grsSource, final boolean rebuild) { final AuthoritativeResource authoritativeResource = grsSource.getAuthoritativeResource(); if (sourceContext.isVirtual(grsSource.getName())) { grsSource.getLogger().info("Not updating GRS data"); } else { acquireAndUpdateGrsData(grsSource, rebuild, authoritativeResource); } resourceTagger.tagObjects(grsSource); } @Autowired GrsSourceImporter(
@Value("${dir.grs.import.download}") final String downloadDir,
final AttributeSanitizer sanitizer,
final ResourceTagger resourceTagger,
final SourceContext sourceContext); } |
@Test(expected = IllegalArgumentException.class) public void validateRangeMoreSpecificsOperatorsOutOfRange() { ParserHelper.validateRangeMoreSpecificsOperators("^0-33"); } | public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } | ParserHelper { public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } } | ParserHelper { public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } private ParserHelper(); } | ParserHelper { public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateRangeMoreSpecificsOperators(final String yytext) { final int dash = yytext.indexOf('-'); int from = Integer.valueOf(yytext.substring(1, dash)); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } int to = Integer.valueOf(yytext.substring(dash + 1)); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } if (to < from) { syntaxError("more specifics operator " + yytext + " not 0 to 32 bits"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test public void validateAsNumber() { ParserHelper.validateAsNumber("AS0"); ParserHelper.validateAsNumber("AS" + ParserHelper.MAX_32BIT_NUMBER); } | public static void validateAsNumber(final String yytext) { final long value = Long.valueOf(yytext.substring(2)); if (value > MAX_32BIT_NUMBER) { syntaxError("AS Number " + yytext + " length is invalid"); } } | ParserHelper { public static void validateAsNumber(final String yytext) { final long value = Long.valueOf(yytext.substring(2)); if (value > MAX_32BIT_NUMBER) { syntaxError("AS Number " + yytext + " length is invalid"); } } } | ParserHelper { public static void validateAsNumber(final String yytext) { final long value = Long.valueOf(yytext.substring(2)); if (value > MAX_32BIT_NUMBER) { syntaxError("AS Number " + yytext + " length is invalid"); } } private ParserHelper(); } | ParserHelper { public static void validateAsNumber(final String yytext) { final long value = Long.valueOf(yytext.substring(2)); if (value > MAX_32BIT_NUMBER) { syntaxError("AS Number " + yytext + " length is invalid"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateAsNumber(final String yytext) { final long value = Long.valueOf(yytext.substring(2)); if (value > MAX_32BIT_NUMBER) { syntaxError("AS Number " + yytext + " length is invalid"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateAsNumberOutOfRange() { ParserHelper.validateAsNumber("AS" + (ParserHelper.MAX_32BIT_NUMBER + 1L)); } | public static void validateAsNumber(final String yytext) { final long value = Long.valueOf(yytext.substring(2)); if (value > MAX_32BIT_NUMBER) { syntaxError("AS Number " + yytext + " length is invalid"); } } | ParserHelper { public static void validateAsNumber(final String yytext) { final long value = Long.valueOf(yytext.substring(2)); if (value > MAX_32BIT_NUMBER) { syntaxError("AS Number " + yytext + " length is invalid"); } } } | ParserHelper { public static void validateAsNumber(final String yytext) { final long value = Long.valueOf(yytext.substring(2)); if (value > MAX_32BIT_NUMBER) { syntaxError("AS Number " + yytext + " length is invalid"); } } private ParserHelper(); } | ParserHelper { public static void validateAsNumber(final String yytext) { final long value = Long.valueOf(yytext.substring(2)); if (value > MAX_32BIT_NUMBER) { syntaxError("AS Number " + yytext + " length is invalid"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateAsNumber(final String yytext) { final long value = Long.valueOf(yytext.substring(2)); if (value > MAX_32BIT_NUMBER) { syntaxError("AS Number " + yytext + " length is invalid"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test public void validateIpv4PrefixRange() { ParserHelper.validateIpv4PrefixRange("128.9.0.0/16^-"); ParserHelper.validateIpv4PrefixRange("5.0.0.0/8^+"); ParserHelper.validateIpv4PrefixRange("30.0.0.0/8^16"); ParserHelper.validateIpv4PrefixRange("30.0.0.0/8^24-32"); } | public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv4PrefixRangeInvalidPrefix() { ParserHelper.validateIpv4PrefixRange("128.9.0.0/33^-"); } | public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv4PrefixRangeInvalidPrefixPlus() { ParserHelper.validateIpv4PrefixRange("128.9.0.0/33^+"); } | public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv4PrefixRangeInvalidPrefixCaretLength() { ParserHelper.validateIpv4PrefixRange("128.9.0.0/8^33"); } | public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv4PrefixRangeInvalidPrefixCaretLengthEndRange() { ParserHelper.validateIpv4PrefixRange("128.9.0.0/8^24-33"); } | public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv4PrefixRangeInvalidPrefixCaretLengthInverseRange() { ParserHelper.validateIpv4PrefixRange("128.9.0.0/8^32-24"); } | public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv4PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv4Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test public void validateIpv6PrefixRange() { ParserHelper.validateIpv6PrefixRange("2001:0DB8::/32^+"); ParserHelper.validateIpv6PrefixRange("2001:0DB8:0100::/48^+"); ParserHelper.validateIpv6PrefixRange("2001:0DB8:0200::/48^64"); ParserHelper.validateIpv6PrefixRange("2001:0DB8:0200::/48^48-64"); ParserHelper.validateIpv6PrefixRange("0::/0^0-128"); ParserHelper.validateIpv6PrefixRange("::/0^0-48"); ParserHelper.validateIpv6PrefixRange("::/0^0-64"); ParserHelper.validateIpv6PrefixRange("::/0^0"); } | public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test public void handleObjects() throws Exception { final File file = new File(getClass().getResource("/grs/radb.test.gz").toURI()); subject.handleObjects(file, objectHandler); assertThat(objectHandler.getObjects(), hasSize(0)); assertThat(objectHandler.getLines(), hasSize(2)); assertThat(objectHandler.getLines(), contains((List<String>) Lists.newArrayList( "aut-num: AS1263\n", "as-name: TEST-AS\n", "descr: TEST-AS\n", "admin-c: Not available\n", "tech-c: See TEST-MNT\n", "mnt-by: TEST-MNT\n", "changed: [email protected] 19950201\n", "source: RADB\n"), Lists.newArrayList( "route: 167.96.0.0/16\n", "" + "descr: Company 2\n" + " Address 2\n" + " Postcode\n" + " State\n" + " Country\n", "origin: AS2900\n", "member-of: RS-TEST\n", "mnt-by: TEST-MNT\n", "changed: [email protected] 19950506\n", "source: RADB\n") )); } | @Override public void handleObjects(final File file, final ObjectHandler handler) throws IOException { FileInputStream is = null; try { is = new FileInputStream(file); final BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(is), StandardCharsets.UTF_8)); handleLines(reader, new LineHandler() { @Override public void handleLines(final List<String> lines) { if (!lines.isEmpty() && !lines.get(0).startsWith("*xx")) { handler.handle(lines); } } }); } finally { IOUtils.closeQuietly(is); } } | RadbGrsSource extends GrsSource { @Override public void handleObjects(final File file, final ObjectHandler handler) throws IOException { FileInputStream is = null; try { is = new FileInputStream(file); final BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(is), StandardCharsets.UTF_8)); handleLines(reader, new LineHandler() { @Override public void handleLines(final List<String> lines) { if (!lines.isEmpty() && !lines.get(0).startsWith("*xx")) { handler.handle(lines); } } }); } finally { IOUtils.closeQuietly(is); } } } | RadbGrsSource extends GrsSource { @Override public void handleObjects(final File file, final ObjectHandler handler) throws IOException { FileInputStream is = null; try { is = new FileInputStream(file); final BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(is), StandardCharsets.UTF_8)); handleLines(reader, new LineHandler() { @Override public void handleLines(final List<String> lines) { if (!lines.isEmpty() && !lines.get(0).startsWith("*xx")) { handler.handle(lines); } } }); } finally { IOUtils.closeQuietly(is); } } @Autowired RadbGrsSource(
@Value("${grs.import.radb.source:}") final String source,
final SourceContext sourceContext,
final DateTimeProvider dateTimeProvider,
final AuthoritativeResourceData authoritativeResourceData,
final Downloader downloader,
@Value("${grs.import.radb.download:}") final String download); } | RadbGrsSource extends GrsSource { @Override public void handleObjects(final File file, final ObjectHandler handler) throws IOException { FileInputStream is = null; try { is = new FileInputStream(file); final BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(is), StandardCharsets.UTF_8)); handleLines(reader, new LineHandler() { @Override public void handleLines(final List<String> lines) { if (!lines.isEmpty() && !lines.get(0).startsWith("*xx")) { handler.handle(lines); } } }); } finally { IOUtils.closeQuietly(is); } } @Autowired RadbGrsSource(
@Value("${grs.import.radb.source:}") final String source,
final SourceContext sourceContext,
final DateTimeProvider dateTimeProvider,
final AuthoritativeResourceData authoritativeResourceData,
final Downloader downloader,
@Value("${grs.import.radb.download:}") final String download); @Override void acquireDump(final Path path); @Override void handleObjects(final File file, final ObjectHandler handler); } | RadbGrsSource extends GrsSource { @Override public void handleObjects(final File file, final ObjectHandler handler) throws IOException { FileInputStream is = null; try { is = new FileInputStream(file); final BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(is), StandardCharsets.UTF_8)); handleLines(reader, new LineHandler() { @Override public void handleLines(final List<String> lines) { if (!lines.isEmpty() && !lines.get(0).startsWith("*xx")) { handler.handle(lines); } } }); } finally { IOUtils.closeQuietly(is); } } @Autowired RadbGrsSource(
@Value("${grs.import.radb.source:}") final String source,
final SourceContext sourceContext,
final DateTimeProvider dateTimeProvider,
final AuthoritativeResourceData authoritativeResourceData,
final Downloader downloader,
@Value("${grs.import.radb.download:}") final String download); @Override void acquireDump(final Path path); @Override void handleObjects(final File file, final ObjectHandler handler); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv6PrefixRangeInvalidPrefix() { ParserHelper.validateIpv6PrefixRange("2001:0DB8::/129^-"); } | public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv6PrefixRangeInvalidPrefixPlus() { ParserHelper.validateIpv6PrefixRange("2001:0DB8::/129^+"); } | public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv6PrefixRangeInvalidPrefixCaretLength() { ParserHelper.validateIpv6PrefixRange("2001:0DB8::/32^129"); } | public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv6PrefixRangeInvalidPrefixCaretLengthEndRange() { ParserHelper.validateIpv6PrefixRange("2001:0DB8::/32^32-129"); } | public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv6PrefixRangeInvalidPrefixCaretLengthInverseRange() { ParserHelper.validateIpv6PrefixRange("2001:0DB8::/32^32-24"); } | public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv6PrefixRange(final String yytext) { Matcher m = ADDRESS_PREFIX_RANGE_PATTERN.matcher(yytext); if (m.matches()) { try { Ipv6Resource.parse(m.group(1)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid quad"); } int prefix = Integer.valueOf(m.group(2)); if (prefix > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid prefix length"); } String fromString = m.group(3); int from = 0; if (fromString != null) { from = Integer.valueOf(fromString); if (from > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } } String toString = m.group(4); if (toString != null) { int to = Integer.valueOf(toString); if (to > MAX_BIT_LENGTH_IPV6) { syntaxError("IP prefix range " + yytext + " contains an invalid range"); } if (to < from) { syntaxError("IP prefix " + yytext + " range end is less than range start"); } } } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test public void validateIpv4Prefix() { ParserHelper.validateIpv4Prefix("0.0.0.0/0"); ParserHelper.validateIpv4Prefix("1.2.3.4/32"); } | public static void validateIpv4Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv4Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix " + yytext + " contains an invalid prefix length"); } } | ParserHelper { public static void validateIpv4Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv4Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix " + yytext + " contains an invalid prefix length"); } } } | ParserHelper { public static void validateIpv4Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv4Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); } | ParserHelper { public static void validateIpv4Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv4Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv4Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv4Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv4PrefixOutOfRange() { ParserHelper.validateIpv4Prefix("1.2.3.4/33"); } | public static void validateIpv4Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv4Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix " + yytext + " contains an invalid prefix length"); } } | ParserHelper { public static void validateIpv4Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv4Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix " + yytext + " contains an invalid prefix length"); } } } | ParserHelper { public static void validateIpv4Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv4Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); } | ParserHelper { public static void validateIpv4Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv4Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv4Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv4Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IP prefix " + yytext + " contains an invalid octet"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV4) { syntaxError("IP prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test public void validateIpv6Prefix() { ParserHelper.validateIpv6Prefix("2001:0DB8::/32"); ParserHelper.validateIpv6Prefix("2001:06f0:0041:0000:0000:0000:3c00:0004/128"); ParserHelper.validateIpv6Prefix("::/0"); ParserHelper.validateIpv6Prefix("2001:503:231d::/48"); } | public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } | ParserHelper { public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } } | ParserHelper { public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); } | ParserHelper { public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv6PrefixOutOfRange() { ParserHelper.validateIpv6Prefix("2001:0DB8::/129"); } | public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } | ParserHelper { public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } } | ParserHelper { public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); } | ParserHelper { public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv6PrefixDoubleColonOutOfRange() { ParserHelper.validateIpv6Prefix("2001:503:231d::/129"); } | public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } | ParserHelper { public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } } | ParserHelper { public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); } | ParserHelper { public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv6Prefix(final String yytext) { final int slash = yytext.indexOf('/'); try { Ipv6Resource.parse(yytext.substring(0, slash)); } catch (IllegalArgumentException e) { syntaxError("IPv6 prefix " + yytext + " contains an invalid quad"); } final int length = Integer.valueOf(yytext.substring(slash + 1)); if (length > MAX_BIT_LENGTH_IPV6) { syntaxError("IPv6 prefix " + yytext + " contains an invalid prefix length"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test public void handleObjects() throws Exception { final File file = new File(getClass().getResource("/grs/arin.test.zip").toURI()); subject.handleObjects(file, objectHandler); assertThat(objectHandler.getLines(), hasSize(0)); assertThat(objectHandler.getObjects(), hasSize(4)); assertThat(objectHandler.getObjects(), contains( RpslObject.parse("" + "aut-num: AS0\n" + "org: IANA\n" + "as-name: IANA-RSVD-0\n" + "remarks: Reserved - May be used to identify non-routed networks\n" + "source: ARIN\n"), RpslObject.parse("" + "inetnum: 192.104.33.0 - 192.104.33.255\n" + "org: THESPI\n" + "netname: SPINK\n" + "status: assignment\n" + "source: ARIN\n"), RpslObject.parse("" + "inet6num: 2001:4d0::/32\n" + "org: NASA\n" + "netname: NASA-PCCA-V6\n" + "status: allocation\n" + "tech-c: ZN7-ARIN\n" + "source: ARIN\n"), RpslObject.parse("" + "inet6num: 2001:468:400::/40\n" + "org: V6IU\n" + "netname: ABILENE-IU-V6\n" + "status: reallocation\n" + "tech-c: BS69-ARIN\n" + "source: ARIN\n") )); } | @Override public void handleObjects(final File file, final ObjectHandler handler) throws IOException { ZipFile zipFile = null; try { zipFile = new ZipFile(file, ZipFile.OPEN_READ); final ZipEntry zipEntry = zipFile.getEntry(zipEntryName); if (zipEntry == null) { logger.error("Zipfile {} does not contain dump {}", file, zipEntryName); return; } final BufferedReader reader = new BufferedReader(new InputStreamReader(zipFile.getInputStream(zipEntry), StandardCharsets.UTF_8)); handleLines(reader, new LineHandler() { @Override public void handleLines(final List<String> lines) { if (lines.isEmpty() || IGNORED_OBJECTS.contains(ciString(StringUtils.substringBefore(lines.get(0), ":")))) { logger.debug("Ignoring:\n\n{}\n", lines); return; } final RpslObjectBuilder rpslObjectBuilder = new RpslObjectBuilder(Joiner.on("").join(lines)); for (RpslObject next : expand(rpslObjectBuilder.getAttributes())) { handler.handle(next); } } private List<RpslObject> expand(final List<RpslAttribute> attributes) { if (attributes.get(0).getKey().equals("ashandle")) { final String asnumber = findAttributeValue(attributes, "asnumber"); if (asnumber != null) { final Matcher rangeMatcher = AS_NUMBER_RANGE.matcher(asnumber); if (rangeMatcher.find()) { final List<RpslObject> objects = Lists.newArrayList(); final int begin = Integer.parseInt(rangeMatcher.group(1)); final int end = Integer.parseInt(rangeMatcher.group(2)); for (int index = begin; index <= end; index++) { attributes.set(0, new RpslAttribute(AttributeType.AUT_NUM, String.format("AS%d", index))); objects.add(new RpslObject(transform(attributes))); } return objects; } } } return Lists.newArrayList(new RpslObject(transform(attributes))); } private List<RpslAttribute> transform(final List<RpslAttribute> attributes) { final List<RpslAttribute> newAttributes = Lists.newArrayList(); for (RpslAttribute attribute : attributes) { final Function<RpslAttribute, RpslAttribute> transformFunction = TRANSFORM_FUNCTIONS.get(ciString(attribute.getKey())); if (transformFunction != null) { attribute = transformFunction.apply(attribute); } final AttributeType attributeType = attribute.getType(); if (attributeType == null) { continue; } else if (AttributeType.INETNUM.equals(attributeType) || AttributeType.INET6NUM.equals(attributeType)) { newAttributes.add(0, attribute); } else { newAttributes.add(attribute); } } return newAttributes; } @Nullable private String findAttributeValue(final List<RpslAttribute> attributes, final String key) { for (RpslAttribute attribute : attributes) { if (attribute.getKey().equals(key)) { return attribute.getCleanValue().toString(); } } return null; } }); } finally { if (zipFile != null) { zipFile.close(); } } } | ArinGrsSource extends GrsSource { @Override public void handleObjects(final File file, final ObjectHandler handler) throws IOException { ZipFile zipFile = null; try { zipFile = new ZipFile(file, ZipFile.OPEN_READ); final ZipEntry zipEntry = zipFile.getEntry(zipEntryName); if (zipEntry == null) { logger.error("Zipfile {} does not contain dump {}", file, zipEntryName); return; } final BufferedReader reader = new BufferedReader(new InputStreamReader(zipFile.getInputStream(zipEntry), StandardCharsets.UTF_8)); handleLines(reader, new LineHandler() { @Override public void handleLines(final List<String> lines) { if (lines.isEmpty() || IGNORED_OBJECTS.contains(ciString(StringUtils.substringBefore(lines.get(0), ":")))) { logger.debug("Ignoring:\n\n{}\n", lines); return; } final RpslObjectBuilder rpslObjectBuilder = new RpslObjectBuilder(Joiner.on("").join(lines)); for (RpslObject next : expand(rpslObjectBuilder.getAttributes())) { handler.handle(next); } } private List<RpslObject> expand(final List<RpslAttribute> attributes) { if (attributes.get(0).getKey().equals("ashandle")) { final String asnumber = findAttributeValue(attributes, "asnumber"); if (asnumber != null) { final Matcher rangeMatcher = AS_NUMBER_RANGE.matcher(asnumber); if (rangeMatcher.find()) { final List<RpslObject> objects = Lists.newArrayList(); final int begin = Integer.parseInt(rangeMatcher.group(1)); final int end = Integer.parseInt(rangeMatcher.group(2)); for (int index = begin; index <= end; index++) { attributes.set(0, new RpslAttribute(AttributeType.AUT_NUM, String.format("AS%d", index))); objects.add(new RpslObject(transform(attributes))); } return objects; } } } return Lists.newArrayList(new RpslObject(transform(attributes))); } private List<RpslAttribute> transform(final List<RpslAttribute> attributes) { final List<RpslAttribute> newAttributes = Lists.newArrayList(); for (RpslAttribute attribute : attributes) { final Function<RpslAttribute, RpslAttribute> transformFunction = TRANSFORM_FUNCTIONS.get(ciString(attribute.getKey())); if (transformFunction != null) { attribute = transformFunction.apply(attribute); } final AttributeType attributeType = attribute.getType(); if (attributeType == null) { continue; } else if (AttributeType.INETNUM.equals(attributeType) || AttributeType.INET6NUM.equals(attributeType)) { newAttributes.add(0, attribute); } else { newAttributes.add(attribute); } } return newAttributes; } @Nullable private String findAttributeValue(final List<RpslAttribute> attributes, final String key) { for (RpslAttribute attribute : attributes) { if (attribute.getKey().equals(key)) { return attribute.getCleanValue().toString(); } } return null; } }); } finally { if (zipFile != null) { zipFile.close(); } } } } | ArinGrsSource extends GrsSource { @Override public void handleObjects(final File file, final ObjectHandler handler) throws IOException { ZipFile zipFile = null; try { zipFile = new ZipFile(file, ZipFile.OPEN_READ); final ZipEntry zipEntry = zipFile.getEntry(zipEntryName); if (zipEntry == null) { logger.error("Zipfile {} does not contain dump {}", file, zipEntryName); return; } final BufferedReader reader = new BufferedReader(new InputStreamReader(zipFile.getInputStream(zipEntry), StandardCharsets.UTF_8)); handleLines(reader, new LineHandler() { @Override public void handleLines(final List<String> lines) { if (lines.isEmpty() || IGNORED_OBJECTS.contains(ciString(StringUtils.substringBefore(lines.get(0), ":")))) { logger.debug("Ignoring:\n\n{}\n", lines); return; } final RpslObjectBuilder rpslObjectBuilder = new RpslObjectBuilder(Joiner.on("").join(lines)); for (RpslObject next : expand(rpslObjectBuilder.getAttributes())) { handler.handle(next); } } private List<RpslObject> expand(final List<RpslAttribute> attributes) { if (attributes.get(0).getKey().equals("ashandle")) { final String asnumber = findAttributeValue(attributes, "asnumber"); if (asnumber != null) { final Matcher rangeMatcher = AS_NUMBER_RANGE.matcher(asnumber); if (rangeMatcher.find()) { final List<RpslObject> objects = Lists.newArrayList(); final int begin = Integer.parseInt(rangeMatcher.group(1)); final int end = Integer.parseInt(rangeMatcher.group(2)); for (int index = begin; index <= end; index++) { attributes.set(0, new RpslAttribute(AttributeType.AUT_NUM, String.format("AS%d", index))); objects.add(new RpslObject(transform(attributes))); } return objects; } } } return Lists.newArrayList(new RpslObject(transform(attributes))); } private List<RpslAttribute> transform(final List<RpslAttribute> attributes) { final List<RpslAttribute> newAttributes = Lists.newArrayList(); for (RpslAttribute attribute : attributes) { final Function<RpslAttribute, RpslAttribute> transformFunction = TRANSFORM_FUNCTIONS.get(ciString(attribute.getKey())); if (transformFunction != null) { attribute = transformFunction.apply(attribute); } final AttributeType attributeType = attribute.getType(); if (attributeType == null) { continue; } else if (AttributeType.INETNUM.equals(attributeType) || AttributeType.INET6NUM.equals(attributeType)) { newAttributes.add(0, attribute); } else { newAttributes.add(attribute); } } return newAttributes; } @Nullable private String findAttributeValue(final List<RpslAttribute> attributes, final String key) { for (RpslAttribute attribute : attributes) { if (attribute.getKey().equals(key)) { return attribute.getCleanValue().toString(); } } return null; } }); } finally { if (zipFile != null) { zipFile.close(); } } } @Autowired ArinGrsSource(
@Value("${grs.import.arin.source:}") final String source,
final SourceContext sourceContext,
final DateTimeProvider dateTimeProvider,
final AuthoritativeResourceData authoritativeResourceData,
final Downloader downloader,
@Value("${grs.import.arin.download:}") final String download,
@Value("${grs.import.arin.zipEntryName:}") final String zipEntryName); } | ArinGrsSource extends GrsSource { @Override public void handleObjects(final File file, final ObjectHandler handler) throws IOException { ZipFile zipFile = null; try { zipFile = new ZipFile(file, ZipFile.OPEN_READ); final ZipEntry zipEntry = zipFile.getEntry(zipEntryName); if (zipEntry == null) { logger.error("Zipfile {} does not contain dump {}", file, zipEntryName); return; } final BufferedReader reader = new BufferedReader(new InputStreamReader(zipFile.getInputStream(zipEntry), StandardCharsets.UTF_8)); handleLines(reader, new LineHandler() { @Override public void handleLines(final List<String> lines) { if (lines.isEmpty() || IGNORED_OBJECTS.contains(ciString(StringUtils.substringBefore(lines.get(0), ":")))) { logger.debug("Ignoring:\n\n{}\n", lines); return; } final RpslObjectBuilder rpslObjectBuilder = new RpslObjectBuilder(Joiner.on("").join(lines)); for (RpslObject next : expand(rpslObjectBuilder.getAttributes())) { handler.handle(next); } } private List<RpslObject> expand(final List<RpslAttribute> attributes) { if (attributes.get(0).getKey().equals("ashandle")) { final String asnumber = findAttributeValue(attributes, "asnumber"); if (asnumber != null) { final Matcher rangeMatcher = AS_NUMBER_RANGE.matcher(asnumber); if (rangeMatcher.find()) { final List<RpslObject> objects = Lists.newArrayList(); final int begin = Integer.parseInt(rangeMatcher.group(1)); final int end = Integer.parseInt(rangeMatcher.group(2)); for (int index = begin; index <= end; index++) { attributes.set(0, new RpslAttribute(AttributeType.AUT_NUM, String.format("AS%d", index))); objects.add(new RpslObject(transform(attributes))); } return objects; } } } return Lists.newArrayList(new RpslObject(transform(attributes))); } private List<RpslAttribute> transform(final List<RpslAttribute> attributes) { final List<RpslAttribute> newAttributes = Lists.newArrayList(); for (RpslAttribute attribute : attributes) { final Function<RpslAttribute, RpslAttribute> transformFunction = TRANSFORM_FUNCTIONS.get(ciString(attribute.getKey())); if (transformFunction != null) { attribute = transformFunction.apply(attribute); } final AttributeType attributeType = attribute.getType(); if (attributeType == null) { continue; } else if (AttributeType.INETNUM.equals(attributeType) || AttributeType.INET6NUM.equals(attributeType)) { newAttributes.add(0, attribute); } else { newAttributes.add(attribute); } } return newAttributes; } @Nullable private String findAttributeValue(final List<RpslAttribute> attributes, final String key) { for (RpslAttribute attribute : attributes) { if (attribute.getKey().equals(key)) { return attribute.getCleanValue().toString(); } } return null; } }); } finally { if (zipFile != null) { zipFile.close(); } } } @Autowired ArinGrsSource(
@Value("${grs.import.arin.source:}") final String source,
final SourceContext sourceContext,
final DateTimeProvider dateTimeProvider,
final AuthoritativeResourceData authoritativeResourceData,
final Downloader downloader,
@Value("${grs.import.arin.download:}") final String download,
@Value("${grs.import.arin.zipEntryName:}") final String zipEntryName); @Override void acquireDump(final Path path); @Override void handleObjects(final File file, final ObjectHandler handler); } | ArinGrsSource extends GrsSource { @Override public void handleObjects(final File file, final ObjectHandler handler) throws IOException { ZipFile zipFile = null; try { zipFile = new ZipFile(file, ZipFile.OPEN_READ); final ZipEntry zipEntry = zipFile.getEntry(zipEntryName); if (zipEntry == null) { logger.error("Zipfile {} does not contain dump {}", file, zipEntryName); return; } final BufferedReader reader = new BufferedReader(new InputStreamReader(zipFile.getInputStream(zipEntry), StandardCharsets.UTF_8)); handleLines(reader, new LineHandler() { @Override public void handleLines(final List<String> lines) { if (lines.isEmpty() || IGNORED_OBJECTS.contains(ciString(StringUtils.substringBefore(lines.get(0), ":")))) { logger.debug("Ignoring:\n\n{}\n", lines); return; } final RpslObjectBuilder rpslObjectBuilder = new RpslObjectBuilder(Joiner.on("").join(lines)); for (RpslObject next : expand(rpslObjectBuilder.getAttributes())) { handler.handle(next); } } private List<RpslObject> expand(final List<RpslAttribute> attributes) { if (attributes.get(0).getKey().equals("ashandle")) { final String asnumber = findAttributeValue(attributes, "asnumber"); if (asnumber != null) { final Matcher rangeMatcher = AS_NUMBER_RANGE.matcher(asnumber); if (rangeMatcher.find()) { final List<RpslObject> objects = Lists.newArrayList(); final int begin = Integer.parseInt(rangeMatcher.group(1)); final int end = Integer.parseInt(rangeMatcher.group(2)); for (int index = begin; index <= end; index++) { attributes.set(0, new RpslAttribute(AttributeType.AUT_NUM, String.format("AS%d", index))); objects.add(new RpslObject(transform(attributes))); } return objects; } } } return Lists.newArrayList(new RpslObject(transform(attributes))); } private List<RpslAttribute> transform(final List<RpslAttribute> attributes) { final List<RpslAttribute> newAttributes = Lists.newArrayList(); for (RpslAttribute attribute : attributes) { final Function<RpslAttribute, RpslAttribute> transformFunction = TRANSFORM_FUNCTIONS.get(ciString(attribute.getKey())); if (transformFunction != null) { attribute = transformFunction.apply(attribute); } final AttributeType attributeType = attribute.getType(); if (attributeType == null) { continue; } else if (AttributeType.INETNUM.equals(attributeType) || AttributeType.INET6NUM.equals(attributeType)) { newAttributes.add(0, attribute); } else { newAttributes.add(attribute); } } return newAttributes; } @Nullable private String findAttributeValue(final List<RpslAttribute> attributes, final String key) { for (RpslAttribute attribute : attributes) { if (attribute.getKey().equals(key)) { return attribute.getCleanValue().toString(); } } return null; } }); } finally { if (zipFile != null) { zipFile.close(); } } } @Autowired ArinGrsSource(
@Value("${grs.import.arin.source:}") final String source,
final SourceContext sourceContext,
final DateTimeProvider dateTimeProvider,
final AuthoritativeResourceData authoritativeResourceData,
final Downloader downloader,
@Value("${grs.import.arin.download:}") final String download,
@Value("${grs.import.arin.zipEntryName:}") final String zipEntryName); @Override void acquireDump(final Path path); @Override void handleObjects(final File file, final ObjectHandler handler); } |
@Test public void validateIpv4() { ParserHelper.validateIpv4("1.2.3.4/32"); } | public static void validateIpv4(final String yytext) { try { Ipv4Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid octet"); } } | ParserHelper { public static void validateIpv4(final String yytext) { try { Ipv4Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid octet"); } } } | ParserHelper { public static void validateIpv4(final String yytext) { try { Ipv4Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid octet"); } } private ParserHelper(); } | ParserHelper { public static void validateIpv4(final String yytext) { try { Ipv4Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid octet"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv4(final String yytext) { try { Ipv4Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid octet"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv4InvalidPrefixLength() { ParserHelper.validateIpv4("1.2.3.4/33"); } | public static void validateIpv4(final String yytext) { try { Ipv4Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid octet"); } } | ParserHelper { public static void validateIpv4(final String yytext) { try { Ipv4Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid octet"); } } } | ParserHelper { public static void validateIpv4(final String yytext) { try { Ipv4Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid octet"); } } private ParserHelper(); } | ParserHelper { public static void validateIpv4(final String yytext) { try { Ipv4Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid octet"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv4(final String yytext) { try { Ipv4Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid octet"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test public void validateIpv6() { ParserHelper.validateIpv6("2001:0DB8::/32"); ParserHelper.validateIpv6("2001:06f0:0041:0000:0000:0000:3c00:0004/128"); ParserHelper.validateIpv6("2001:470:1:35e::1"); ParserHelper.validateIpv6("2001:7F8:14::58:2"); ParserHelper.validateIpv6("2001:7f8:13::a500:8587:1"); ParserHelper.validateIpv6("2001:504:1::"); } | public static void validateIpv6(final String yytext) { try { Ipv6Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid quad"); } } | ParserHelper { public static void validateIpv6(final String yytext) { try { Ipv6Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid quad"); } } } | ParserHelper { public static void validateIpv6(final String yytext) { try { Ipv6Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid quad"); } } private ParserHelper(); } | ParserHelper { public static void validateIpv6(final String yytext) { try { Ipv6Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid quad"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv6(final String yytext) { try { Ipv6Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid quad"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
@Test(expected = IllegalArgumentException.class) public void validateIpv6InvalidPrefixLength() { ParserHelper.validateIpv6("2001:0DB8::/129"); } | public static void validateIpv6(final String yytext) { try { Ipv6Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid quad"); } } | ParserHelper { public static void validateIpv6(final String yytext) { try { Ipv6Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid quad"); } } } | ParserHelper { public static void validateIpv6(final String yytext) { try { Ipv6Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid quad"); } } private ParserHelper(); } | ParserHelper { public static void validateIpv6(final String yytext) { try { Ipv6Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid quad"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } | ParserHelper { public static void validateIpv6(final String yytext) { try { Ipv6Resource.parse(yytext); } catch (IllegalArgumentException e) { syntaxError("IP address " + yytext + " contains an invalid quad"); } } private ParserHelper(); static void check16bit(final String number); static void check32bit(final String number); static void checkMaskLength(final String maskLength); static void checkMaskLengthv6(final String maskLength); static void checkStringLength(final String ip, final int maxAllowedLength); static void validateMoreSpecificsOperator(final String yytext); static void validateRangeMoreSpecificsOperators(final String yytext); static void validateAsNumber(final String yytext); static void validateIpv4PrefixRange(final String yytext); static void validateIpv6PrefixRange(final String yytext); static void validateIpv4Prefix(final String yytext); static void validateIpv6Prefix(final String yytext); static void validateIpv4(final String yytext); static void validateIpv6(final String yytext); static void validateCommunity(final String yytext); static void validateDomainName(final String yytext); static void validateDomainNameLabel(final String yytext); static void validateSmallInt(final String yytext); static void validateAsRange(final String yytext); static void log(final String message); static void log(final Exception exception); static void syntaxError(final String message); static void parserError(final String message); } |
Subsets and Splits