method2testcases stringlengths 118 6.63k |
|---|
### Question:
FormatHelper { public static String dateToString(final TemporalAccessor temporalAccessor) { if (temporalAccessor == null) { return null; } return DATE_FORMAT.format(temporalAccessor); } private FormatHelper(); static String dateToString(final TemporalAccessor temporalAccessor); static String dateTimeToSt... |
### Question:
NicHandleFactory extends AbstractAutoKeyFactory<NicHandle> { @Override public NicHandle generate(final String keyPlaceHolder, final RpslObject object) { return generateForName(keyPlaceHolder, object.getTypeAttribute().getCleanValue().toString()); } @Autowired NicHandleFactory(final NicHandleRepository ni... |
### Question:
NicHandleFactory extends AbstractAutoKeyFactory<NicHandle> { @Override public AttributeType getAttributeType() { return AttributeType.NIC_HDL; } @Autowired NicHandleFactory(final NicHandleRepository nicHandleRepository, final CountryCodeRepository countryCodeRepository); @Override AttributeType getAttrib... |
### Question:
NicHandleFactory extends AbstractAutoKeyFactory<NicHandle> { @Override public NicHandle claim(final String key) throws ClaimException { final NicHandle nicHandle = parseNicHandle(key); if (!nicHandleRepository.claimSpecified(nicHandle)) { throw new ClaimException(UpdateMessages.nicHandleNotAvailable(nicHa... |
### Question:
OrganisationIdFactory extends AbstractAutoKeyFactory<OrganisationId> { @Override public OrganisationId generate(final String keyPlaceHolder, final RpslObject object) { return generateForName(keyPlaceHolder, object.getValueForAttribute(AttributeType.ORG_NAME).toString()); } @Autowired OrganisationIdFactor... |
### Question:
OrganisationIdFactory extends AbstractAutoKeyFactory<OrganisationId> { @Override public AttributeType getAttributeType() { return AttributeType.ORGANISATION; } @Autowired OrganisationIdFactory(final OrganisationIdRepository organisationIdRepository); @Override AttributeType getAttributeType(); @Override ... |
### Question:
OrganisationIdFactory extends AbstractAutoKeyFactory<OrganisationId> { @Override public OrganisationId claim(final String key) throws ClaimException { throw new ClaimException(ValidationMessages.syntaxError(key, "must be AUTO-nnn for create")); } @Autowired OrganisationIdFactory(final OrganisationIdRepos... |
### Question:
X509CertificateWrapper implements KeyWrapper { static boolean looksLikeX509Key(final RpslObject rpslObject) { final String pgpKey = RpslObjectFilter.getCertificateFromKeyCert(rpslObject); return pgpKey.indexOf(X509_HEADER) != -1 && pgpKey.indexOf(X509_FOOTER) != -1; } private X509CertificateWrapper(final... |
### Question:
X509CertificateWrapper implements KeyWrapper { @Override public String getMethod() { return METHOD; } private X509CertificateWrapper(final X509Certificate certificate); static X509CertificateWrapper parse(final RpslObject rpslObject); static X509CertificateWrapper parse(final byte[] certificate); @Overri... |
### Question:
X509CertificateWrapper implements KeyWrapper { @Override public String getFingerprint() { try { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] der = certificate.getEncoded(); md.update(der); byte[] digest = md.digest(); StringBuilder builder = new StringBuilder(); for (byte next : digest) { i... |
### Question:
X509CertificateWrapper implements KeyWrapper { public boolean isExpired(final DateTimeProvider dateTimeProvider) { final LocalDateTime notAfter = DateUtil.fromDate(certificate.getNotAfter()); return notAfter.isBefore(dateTimeProvider.getCurrentDateTime()); } private X509CertificateWrapper(final X509Certi... |
### Question:
FormatHelper { public static String dateTimeToString(final TemporalAccessor temporalAccessor) { if (temporalAccessor == null) { return null; } if (temporalAccessor.isSupported(ChronoField.HOUR_OF_DAY)) { return DATE_TIME_FORMAT.format(temporalAccessor); } return DATE_FORMAT.format(temporalAccessor); } pri... |
### Question:
PgpPublicKeyWrapper implements KeyWrapper { static boolean looksLikePgpKey(final RpslObject rpslObject) { final String pgpKey = RpslObjectFilter.getCertificateFromKeyCert(rpslObject); return pgpKey.indexOf(PGP_HEADER) != -1 && pgpKey.indexOf(PGP_FOOTER) != -1; } PgpPublicKeyWrapper(final PGPPublicKey mast... |
### Question:
X509SignedMessage { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final X509SignedMessage that = (X509SignedMessage) o; return Objects.equals(signature, that.signature); } X509SignedMessage(final String signedData, ... |
### Question:
LoggingHandlerAdapter implements LoggingHandler { @Override public void log(final StatementInfo statementInfo, final ResultInfo resultInfo) { loggerContext.logQuery(statementInfo, resultInfo); } @Autowired LoggingHandlerAdapter(final LoggerContext loggerContext); @Override void log(final StatementInfo st... |
### Question:
UpdateLog { public void logUpdateResult(final UpdateRequest updateRequest, final UpdateContext updateContext, final Update update, final Stopwatch stopwatch) { logger.info(formatMessage(updateRequest, updateContext, update, stopwatch)); } UpdateLog(); UpdateLog(final Logger logger); void logUpdateResult(... |
### Question:
AuditLogger { public void logException(final Update update, final Throwable throwable) { final Element updateElement = createOrGetUpdateElement(update); final Element exceptionElement = doc.createElement("exception"); updateElement.appendChild(exceptionElement); exceptionElement.appendChild(keyValue("clas... |
### Question:
AuditLogger { public void logDuration(final Update update, final String duration) { final Element updateElement = createOrGetUpdateElement(update); updateElement.appendChild(keyValue("duration", duration)); } AuditLogger(final DateTimeProvider dateTimeProvider, final OutputStream outputStream); @SuppressW... |
### Question:
AuditLogger { public void close() { try { writeAndClose(); } catch (IOException e) { LOGGER.error("IO Exception", e); } } AuditLogger(final DateTimeProvider dateTimeProvider, final OutputStream outputStream); @SuppressWarnings("ThrowableResultOfMethodCallIgnored" /* Throwable is logged */) void log(final ... |
### Question:
LoggerContext { public void checkDirs() { getCreatedDir(baseDir); } @Autowired LoggerContext(final DateTimeProvider dateTimeProvider); void setBaseDir(final String baseDir); @PostConstruct void start(); void checkDirs(); void init(final String folderName); void remove(); File getFile(final String filenam... |
### Question:
LoggerContext { public File getFile(final String filename) { final Context tempContext = getContext(); return getFile(tempContext.baseDir, tempContext.nextFileNumber(), filename); } @Autowired LoggerContext(final DateTimeProvider dateTimeProvider); void setBaseDir(final String baseDir); @PostConstruct vo... |
### Question:
LoggerContext { public File log(final String name, final LogCallback callback) { final File file = getFile(name); OutputStream os = null; try { os = getOutputstream(file); callback.log(os); } catch (IOException e) { throw new IllegalStateException("Unable to write to " + file.getAbsolutePath(), e); } fina... |
### Question:
LoggerContext { public void logQuery(final StatementInfo statementInfo, final ResultInfo resultInfo) { final Context ctx = context.get(); if (ctx != null && ctx.currentUpdate != null) { ctx.auditLogger.logQuery(ctx.currentUpdate, statementInfo, resultInfo); } } @Autowired LoggerContext(final DateTimeProv... |
### Question:
LoggerContext { public void logUpdateCompleted(final UpdateContainer updateContainer) { logUpdateComplete(updateContainer, null); } @Autowired LoggerContext(final DateTimeProvider dateTimeProvider); void setBaseDir(final String baseDir); @PostConstruct void start(); void checkDirs(); void init(final Stri... |
### Question:
LoggerContext { public void logException(final UpdateContainer updateContainer, final Throwable throwable) { getContext().auditLogger.logException(updateContainer.getUpdate(), throwable); } @Autowired LoggerContext(final DateTimeProvider dateTimeProvider); void setBaseDir(final String baseDir); @PostCons... |
### Question:
MailMessageLogCallback implements LogCallback { @Override public void log(final OutputStream outputStream) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { message.writeTo(baos); String messageData = new String( baos.toByteArray(), "UTF-8" ); String filtered = PasswordF... |
### Question:
IterableTransformer implements Iterable<T> { @Override public Iterator<T> iterator() { return new IteratorTransformer(head); } IterableTransformer(final Iterable<? extends T> wrap); IterableTransformer<T> setHeader(T... header); IterableTransformer<T> setHeader(Collection<T> header); abstract void apply(f... |
### Question:
GrsImporter implements DailyScheduledTask { @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "GrsImporter") public void run() { if (!grsImportEnabled) { LOGGER.info("GRS import is not enabled"); return; } List<Future> futures = grsImport(defaultSources, false); for (Future future : futures... |
### Question:
MailGatewaySmtp implements MailGateway { @Override public void sendEmail(final String to, final ResponseMessage responseMessage) { sendEmail(to, responseMessage.getSubject(), responseMessage.getMessage(), responseMessage.getReplyTo()); } @Autowired MailGatewaySmtp(final LoggerContext loggerContext, final... |
### Question:
OverrideCredential implements Credential { @Override public String toString() { if (!overrideValues.isPresent()){ return "OverrideCredential{NOT_VALID}"; } if (StringUtils.isBlank(overrideValues.get().getRemarks())){ return String.format("OverrideCredential{%s,FILTERED}", overrideValues.get().getUsername(... |
### Question:
LegacyAutnum { public boolean contains(final CIString autnum) { return cachedLegacyAutnums.contains(autnum); } @Autowired LegacyAutnum(final LegacyAutnumDao legacyAutnumDao); @PostConstruct synchronized void init(); boolean contains(final CIString autnum); int getTotal(); }### Answer:
@Test public void ... |
### Question:
OrganisationId extends AutoKey { @Override public String toString() { return new StringBuilder() .append("ORG-") .append(getSpace().toUpperCase()) .append(getIndex()) .append("-") .append(getSuffix()) .toString(); } OrganisationId(final String space, final int index, final String suffix); @Override String... |
### Question:
NicHandle extends AutoKey { public static NicHandle parse(final String nicHdl, final CIString source, final Set<CIString> countryCodes) { if (StringUtils.startsWithIgnoreCase(nicHdl, "AUTO-")) { throw new NicHandleParseException("Primary key generation request cannot be parsed as NIC-HDL: " + nicHdl); } f... |
### Question:
UpdateContext { public Messages getGlobalMessages() { return globalMessages; } UpdateContext(final LoggerContext loggerContext); boolean isDryRun(); void dryRun(); int getNrSinceRestart(); boolean isBatchUpdate(); void setBatchUpdate(); void addDnsCheckResponse(final DnsCheckRequest request, final DnsChec... |
### Question:
UpdateContext { public boolean hasErrors(final UpdateContainer updateContainer) { return getOrCreateContext(updateContainer).objectMessages.hasErrors(); } UpdateContext(final LoggerContext loggerContext); boolean isDryRun(); void dryRun(); int getNrSinceRestart(); boolean isBatchUpdate(); void setBatchUpd... |
### Question:
UpdateContext { public void status(final UpdateContainer updateContainer, final UpdateStatus status) { getOrCreateContext(updateContainer).status = status; loggerContext.logStatus(updateContainer, status); } UpdateContext(final LoggerContext loggerContext); boolean isDryRun(); void dryRun(); int getNrSinc... |
### Question:
ContentWithCredentials { public List<Credential> getCredentials() { return credentials; } ContentWithCredentials(final String content); ContentWithCredentials(final String content, final Charset charset); ContentWithCredentials(final String content, final List<Credential> credentials); ContentWithCrede... |
### Question:
PreparedUpdate implements UpdateContainer { @Override public Update getUpdate() { return update; } PreparedUpdate(final Update update, @Nullable final RpslObject originalObject, @Nullable final RpslObject updatedObject, final Action action); PreparedUpdate(final Update update, @Nullable final RpslObject ... |
### Question:
PreparedUpdate implements UpdateContainer { public Paragraph getParagraph() { return update.getParagraph(); } PreparedUpdate(final Update update, @Nullable final RpslObject originalObject, @Nullable final RpslObject updatedObject, final Action action); PreparedUpdate(final Update update, @Nullable final ... |
### Question:
PreparedUpdate implements UpdateContainer { @Nullable public RpslObject getReferenceObject() { if (originalObject != null) { return originalObject; } return updatedObject; } PreparedUpdate(final Update update, @Nullable final RpslObject originalObject, @Nullable final RpslObject updatedObject, final Actio... |
### Question:
PreparedUpdate implements UpdateContainer { @Nullable public RpslObject getUpdatedObject() { return updatedObject; } PreparedUpdate(final Update update, @Nullable final RpslObject originalObject, @Nullable final RpslObject updatedObject, final Action action); PreparedUpdate(final Update update, @Nullable... |
### Question:
PreparedUpdate implements UpdateContainer { public Action getAction() { return action; } PreparedUpdate(final Update update, @Nullable final RpslObject originalObject, @Nullable final RpslObject updatedObject, final Action action); PreparedUpdate(final Update update, @Nullable final RpslObject originalOb... |
### Question:
PreparedUpdate implements UpdateContainer { public Credentials getCredentials() { return update.getCredentials(); } PreparedUpdate(final Update update, @Nullable final RpslObject originalObject, @Nullable final RpslObject updatedObject, final Action action); PreparedUpdate(final Update update, @Nullable ... |
### Question:
PreparedUpdate implements UpdateContainer { public ObjectType getType() { return update.getType(); } PreparedUpdate(final Update update, @Nullable final RpslObject originalObject, @Nullable final RpslObject updatedObject, final Action action); PreparedUpdate(final Update update, @Nullable final RpslObjec... |
### Question:
PreparedUpdate implements UpdateContainer { public String getKey() { return updatedObject.getKey().toString(); } PreparedUpdate(final Update update, @Nullable final RpslObject originalObject, @Nullable final RpslObject updatedObject, final Action action); PreparedUpdate(final Update update, @Nullable fin... |
### Question:
ObjectKey { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final ObjectKey that = (ObjectKey) o; return Objects.equals(objectType, that.objectType) && Objects.equals(pkey, that.pkey); } ObjectKey(final ObjectType objectTyp... |
### Question:
ObjectKey { @Override public int hashCode() { return Objects.hash(objectType, pkey); } ObjectKey(final ObjectType objectType, final String pkey); ObjectKey(final ObjectType objectType, final CIString pkey); ObjectType getObjectType(); CIString getPkey(); @Override boolean equals(Object o); @Override int ... |
### Question:
ObjectKey { @Override public String toString() { return String.format("[%s] %s", objectType.getName(), pkey); } ObjectKey(final ObjectType objectType, final String pkey); ObjectKey(final ObjectType objectType, final CIString pkey); ObjectType getObjectType(); CIString getPkey(); @Override boolean equals(... |
### Question:
Notification { public String getEmail() { return email; } Notification(final String email); void add(final Type type, final PreparedUpdate update, UpdateContext updateContext); String getEmail(); Set<Update> getUpdates(final Type type); boolean has(final Type type); }### Answer:
@Test public void getEmai... |
### Question:
Notification { public Set<Update> getUpdates(final Type type) { return updates.get(type); } Notification(final String email); void add(final Type type, final PreparedUpdate update, UpdateContext updateContext); String getEmail(); Set<Update> getUpdates(final Type type); boolean has(final Type type); }###... |
### Question:
Notification { public boolean has(final Type type) { return !updates.get(type).isEmpty(); } Notification(final String email); void add(final Type type, final PreparedUpdate update, UpdateContext updateContext); String getEmail(); Set<Update> getUpdates(final Type type); boolean has(final Type type); }###... |
### Question:
UpdateResult { @Override public String toString() { final Writer writer = new StringWriter(); try { toString(writer); return writer.toString(); } catch (IOException e) { throw new IllegalStateException("Should not occur", e); } } UpdateResult(@Nullable final RpslObject originalObject, final RpslObject upd... |
### Question:
Credentials { public boolean has(final Class<? extends Credential> clazz) { return !ofType(clazz).isEmpty(); } Credentials(); Credentials(final Set<? extends Credential> credentials); Credentials add(final Collection<Credential> addedCredentials); Set<Credential> all(); T single(final Class<T> clazz); Se... |
### Question:
Update implements UpdateContainer { public boolean isSigned() { return paragraph.getCredentials().has(PgpCredential.class) || paragraph.getCredentials().has(X509Credential.class); } Update(final Paragraph paragraph, final Operation operation, @Nullable final List<String> deleteReasons, final RpslObject su... |
### Question:
Update implements UpdateContainer { public boolean isOverride() { return paragraph.getCredentials().has(OverrideCredential.class); } Update(final Paragraph paragraph, final Operation operation, @Nullable final List<String> deleteReasons, final RpslObject submittedObject); @Override Update getUpdate(); Par... |
### Question:
ProxyIterable implements Iterable<R> { @Override public Iterator<R> iterator() { return new Iterator<R>() { private final Iterator<P> sourceIterator = source.iterator(); private List<R> batch = initialBatch; private int idx; @Override public boolean hasNext() { return idx < batch.size() || sourceIterator.... |
### Question:
NrtmConnectionPerIpLimitHandler extends SimpleChannelUpstreamHandler { private boolean connectionsExceeded(final InetAddress remoteAddresss) { final Integer count = connectionCounter.increment(remoteAddresss); return (count != null && count > maxConnectionsPerIp); } @Autowired NrtmConnectionPerIpLimitHan... |
### Question:
SocketChannelFactory { public static Reader createReader(final SocketChannel socketChannel) { return new Reader(socketChannel); } private SocketChannelFactory(); static SocketChannel createSocketChannel(final String host, final int port); static Reader createReader(final SocketChannel socketChannel); sta... |
### Question:
SocketChannelFactory { public static Writer createWriter(final SocketChannel socketChannel) { return new Writer(socketChannel); } private SocketChannelFactory(); static SocketChannel createSocketChannel(final String host, final int port); static Reader createReader(final SocketChannel socketChannel); sta... |
### Question:
NrtmImporter implements EmbeddedValueResolverAware, ApplicationService { @PostConstruct void checkSources() { for (final CIString source : sources) { if (sourceContext.isVirtual(source)) { throw new IllegalArgumentException(String.format("Cannot use NRTM with virtual source: %s", source)); } JdbcRpslObjec... |
### Question:
NrtmImporter implements EmbeddedValueResolverAware, ApplicationService { @Override public void start() { if (!enabled) { return; } final List<NrtmSource> nrtmSources = readNrtmSources(); if (nrtmSources.size() > 0) { LOGGER.info("Initializing thread pool with {} thread(s)", nrtmSources.size()); executorSe... |
### Question:
NrtmQueryHandler extends SimpleChannelUpstreamHandler { @Override public void channelConnected(final ChannelHandlerContext ctx, final ChannelStateEvent e) throws Exception { PendingWrites.add(ctx.getChannel()); writeMessage(ctx.getChannel(), NrtmMessages.termsAndConditions()); super.channelConnected(ctx, ... |
### Question:
NrtmExceptionHandler extends SimpleChannelUpstreamHandler { @Override public void exceptionCaught(final ChannelHandlerContext ctx, final ExceptionEvent event) { final Channel channel = event.getChannel(); final Throwable exception = event.getCause(); if (!channel.isOpen()) { return; } if (exception instan... |
### Question:
CollectionHelper { public static <T> T uniqueResult(final Collection<T> c) { switch (c.size()) { case 0: return null; case 1: return c.iterator().next(); default: throw new IllegalStateException("Unexpected number of elements in collection: " + c.size()); } } private CollectionHelper(); static T uniqueRe... |
### Question:
GrsImporter implements DailyScheduledTask { public List<Future> grsImport(String sources, final boolean rebuild) { final Set<CIString> sourcesToImport = splitSources(sources); LOGGER.info("GRS import sources: {}", sourcesToImport); final List<Future> futures = Lists.newArrayListWithCapacity(sourcesToImpor... |
### Question:
CollectionHelper { public static Iterable<ResponseObject> iterateProxy( final ProxyLoader<Identifiable, RpslObject> rpslObjectLoader, final Iterable<? extends Identifiable> identifiables) { final ProxyIterable<Identifiable, ? extends ResponseObject> rpslObjects = new ProxyIterable<>((Iterable<Identifiable... |
### Question:
DatabaseMaintenanceJmx extends JmxBase { @ManagedOperation(description = "Recovers a deleted object (you will need to issue an IP tree rebuild if needed)") @ManagedOperationParameters({ @ManagedOperationParameter(name = "objectId", description = "Id of the object to recover"), @ManagedOperationParameter(n... |
### Question:
IndexStrategyAdapter implements IndexStrategy { @Override public final AttributeType getAttributeType() { return attributeType; } IndexStrategyAdapter(final AttributeType attributeType); @Override final AttributeType getAttributeType(); @Override final int addToIndex(final JdbcTemplate jdbcTemplate, final... |
### Question:
IndexStrategyAdapter implements IndexStrategy { @Override public final int addToIndex(final JdbcTemplate jdbcTemplate, final RpslObjectInfo objectInfo, final RpslObject object, final CIString value) { return addToIndex(jdbcTemplate, objectInfo, object, value.toString()); } IndexStrategyAdapter(final Attri... |
### Question:
IndexStrategyAdapter implements IndexStrategy { @Override public final List<RpslObjectInfo> findInIndex(final JdbcTemplate jdbcTemplate, final CIString value) { return findInIndex(jdbcTemplate, value.toString()); } IndexStrategyAdapter(final AttributeType attributeType); @Override final AttributeType getA... |
### Question:
IndexStrategyAdapter implements IndexStrategy { @Override public void removeFromIndex(final JdbcTemplate jdbcTemplate, final RpslObjectInfo objectInfo) { } IndexStrategyAdapter(final AttributeType attributeType); @Override final AttributeType getAttributeType(); @Override final int addToIndex(final JdbcTe... |
### Question:
IndexStrategyAdapter implements IndexStrategy { @Override public String getLookupTableName() { return null; } IndexStrategyAdapter(final AttributeType attributeType); @Override final AttributeType getAttributeType(); @Override final int addToIndex(final JdbcTemplate jdbcTemplate, final RpslObjectInfo obje... |
### Question:
IndexStrategyAdapter implements IndexStrategy { @Override public String getLookupColumnName() { return null; } IndexStrategyAdapter(final AttributeType attributeType); @Override final AttributeType getAttributeType(); @Override final int addToIndex(final JdbcTemplate jdbcTemplate, final RpslObjectInfo obj... |
### Question:
IndexStrategies { public static IndexStrategy get(final AttributeType attributeType) { return INDEX_BY_ATTRIBUTE.get(attributeType); } private IndexStrategies(); static IndexStrategy get(final AttributeType attributeType); static List<IndexStrategy> getReferencing(final ObjectType objectType); }### Answ... |
### Question:
ObjectTypeIds { public static ObjectType getType(final int serialType) throws IllegalArgumentException { final ObjectType objectType = BY_TYPE_ID.get(serialType); if (objectType == null) { throw new IllegalArgumentException("Object type with objectTypeId " + serialType + " not found"); } return objectType... |
### Question:
SourceAwareDataSource extends AbstractDataSource { @Override public Connection getConnection() throws SQLException { return getActualDataSource().getConnection(); } @Autowired SourceAwareDataSource(final BasicSourceContext sourceContext); @Override Connection getConnection(); @Override Connection getConn... |
### Question:
DatabaseVersionCheck { public static int compareVersions(final String v1, final String v2) { Iterator<String> i1 = VERSION_SPLITTER.split(v1).iterator(); Iterator<String> i2 = VERSION_SPLITTER.split(v2).iterator(); while (i1.hasNext() && i2.hasNext()) { int res = Integer.parseInt(i1.next()) - Integer.pars... |
### Question:
DatabaseVersionCheck { public void checkDatabase(Iterable<String> resources, String dataSourceName, String dbVersion) { final Matcher dbVersionMatcher = RESOURCE_MATCHER.matcher(dbVersion); if (!dbVersionMatcher.matches()) { throw new IllegalStateException("Invalid version: " + dbVersion); } for (String r... |
### Question:
DateUtil { public static LocalDateTime fromDate(final Date date) { return Instant.ofEpochMilli(date.getTime()) .atZone(ZoneOffset.systemDefault()) .toLocalDateTime(); } private DateUtil(); static Date toDate(final LocalDateTime localDateTime); static Date toDate(final LocalDate localDate); static LocalDa... |
### Question:
DateUtil { public static Date toDate(final LocalDateTime localDateTime) { return Date.from(localDateTime.atZone(ZoneOffset.systemDefault()) .toInstant()); } private DateUtil(); static Date toDate(final LocalDateTime localDateTime); static Date toDate(final LocalDate localDate); static LocalDateTime fromD... |
### Question:
BlockEvent { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final BlockEvent that = (BlockEvent) o; return Objects.equals(time, that.time) && Objects.equals(type, that.type); } BlockEvent(final LocalDateTime time, final in... |
### Question:
BlockEvents { public int getTemporaryBlockCount() { int numberOfBlocks = 0; for (final BlockEvent blockEvent : blockEvents) { switch (blockEvent.getType()) { case BLOCK_TEMPORARY: numberOfBlocks++; break; case UNBLOCK: case BLOCK_PERMANENTLY: return numberOfBlocks; default: throw new IllegalStateException... |
### Question:
BlockEvents { public boolean isPermanentBlockRequired() { return getTemporaryBlockCount() >= NR_TEMP_BLOCKS_BEFORE_PERMANENT; } BlockEvents(final String prefix, final List<BlockEvent> blockEvents); String getPrefix(); int getTemporaryBlockCount(); boolean isPermanentBlockRequired(); static final int NR_TE... |
### Question:
ConcurrentState { public void set(final Boolean value) { updates.add(value); } void set(final Boolean value); void waitUntil(final Boolean value); }### Answer:
@Test public void set_and_unset_state() { Counter counter = new Counter(); new Thread(counter).start(); subject.set(true); waitForExpectedValue(... |
### Question:
IpResourceTree { public V getValue(IpInterval<?> ipInterval) { List<V> list = getTree(ipInterval).findExactOrFirstLessSpecific(ipInterval); return CollectionHelper.uniqueResult(list); } @SuppressWarnings({"unchecked", "rawtypes"}) IpResourceTree(); void add(IpInterval<?> ipInterval, V value); V getValue(... |
### Question:
ApnicGrsSource 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), Standar... |
### Question:
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<BlockEv... |
### Question:
SynchronizedIntervalMap implements IntervalMap<K, V> { @Override public void put(K key, V value) { synchronized (mutex) { wrapped.put(key, value); } } private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped); private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped, final Object mutex); s... |
### Question:
SynchronizedIntervalMap implements IntervalMap<K, V> { @Override public void remove(K key) { synchronized (mutex) { wrapped.remove(key); } } private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped); private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped, final Object mutex); static Inte... |
### Question:
SynchronizedIntervalMap implements IntervalMap<K, V> { @Override public List<V> findFirstLessSpecific(K key) { synchronized (mutex) { return wrapped.findFirstLessSpecific(key); } } private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped); private SynchronizedIntervalMap(final IntervalMap<K, V> w... |
### Question:
SynchronizedIntervalMap implements IntervalMap<K, V> { @Override public List<V> findAllLessSpecific(K key) { synchronized (mutex) { return wrapped.findAllLessSpecific(key); } } private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped); private SynchronizedIntervalMap(final IntervalMap<K, V> wrapp... |
### Question:
SynchronizedIntervalMap implements IntervalMap<K, V> { @Override public List<V> findExactAndAllLessSpecific(K key) { synchronized (mutex) { return wrapped.findExactAndAllLessSpecific(key); } } private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped); private SynchronizedIntervalMap(final Interva... |
### Question:
SynchronizedIntervalMap implements IntervalMap<K, V> { @Override public List<V> findExact(K key) { synchronized (mutex) { return wrapped.findExact(key); } } private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped); private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped, final Object mut... |
### Question:
SynchronizedIntervalMap implements IntervalMap<K, V> { @Override public List<V> findExactOrFirstLessSpecific(K key) { synchronized (mutex) { return wrapped.findExactOrFirstLessSpecific(key); } } private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped); private SynchronizedIntervalMap(final Inter... |
### Question:
SynchronizedIntervalMap implements IntervalMap<K, V> { @Override public List<V> findFirstMoreSpecific(K key) { synchronized (mutex) { return wrapped.findFirstMoreSpecific(key); } } private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped); private SynchronizedIntervalMap(final IntervalMap<K, V> w... |
### Question:
SynchronizedIntervalMap implements IntervalMap<K, V> { @Override public List<V> findAllMoreSpecific(K key) { synchronized (mutex) { return wrapped.findAllMoreSpecific(key); } } private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped); private SynchronizedIntervalMap(final IntervalMap<K, V> wrapp... |
### Question:
LacnicGrsSource 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(is, StandardCharsets.UTF_8)); h... |
### Question:
SynchronizedIntervalMap implements IntervalMap<K, V> { @Override public List<V> findExactAndAllMoreSpecific(K key) { synchronized (mutex) { return wrapped.findExactAndAllMoreSpecific(key); } } private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped); private SynchronizedIntervalMap(final Interva... |
### Question:
SynchronizedIntervalMap implements IntervalMap<K, V> { @Override public void clear() { synchronized (mutex) { wrapped.clear(); } } private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped); private SynchronizedIntervalMap(final IntervalMap<K, V> wrapped, final Object mutex); static IntervalMap<K,... |
### Question:
InternalNode { void addChild(InternalNode<K, V> nodeToAdd) { if (interval.equals(nodeToAdd.getInterval())) { this.value = nodeToAdd.getValue(); } else if (!interval.contains(nodeToAdd.getInterval())) { throw new IllegalArgumentException(nodeToAdd.getInterval() + " not properly contained in " + interval); ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.