method2testcases
stringlengths
118
6.63k
### Question: SlotKeySerDes { protected static int shardFromSlotKey(String s) { return Integer.parseInt(s.split(",", -1)[2]); } static SlotKey deserialize(String stateStr); String serialize(SlotKey slotKey); String serialize(Granularity gran, int slot, int shard); }### Answer: @Test public void testShardFromSlotKey()...
### Question: SimpleNumber implements Rollup { public String toString() { switch (type) { case INTEGER: return String.format("%d (int)", value.intValue()); case LONG: return String.format("%d (long)", value.longValue()); case DOUBLE: return String.format("%s (double)", value.toString()); default: return super.toString(...
### Question: SimpleNumber implements Rollup { @Override public RollupType getRollupType() { return RollupType.NOT_A_ROLLUP; } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override bool...
### Question: SimpleNumber implements Rollup { @Override public int hashCode() { return value.hashCode(); } SimpleNumber(Object value); @Override Boolean hasData(); Number getValue(); Type getDataType(); String toString(); @Override RollupType getRollupType(); @Override int hashCode(); @Override boolean equals(Object o...
### Question: SimpleNumber implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof SimpleNumber)) return false; SimpleNumber other = (SimpleNumber)obj; return other.value == this.value || other.value.equals(this.value); } SimpleNumber(Object value); @Override Boolean hasDat...
### Question: RollupService implements Runnable, RollupServiceMBean { public synchronized boolean getActive() { return active; } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context, ShardStateManager shardStateManager, Threa...
### Question: BluefloodTimerRollup implements Rollup, IBaseRollup { public static double calculatePerSecond(long countA, double countPerSecA, long countB, double countPerSecB) { double totalCount = countA + countB; double totalTime = ((double)countA / countPerSecA) + ((double)countB / countPerSecB); return totalCount /...
### Question: BluefloodTimerRollup implements Rollup, IBaseRollup { public BluefloodTimerRollup withSampleCount(int sampleCount) { this.sampleCount = sampleCount; return this; } BluefloodTimerRollup(); BluefloodTimerRollup withSum(double sum); BluefloodTimerRollup withCount(long count); BluefloodTimerRollup withCountPS...
### Question: BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number sum(Collection<Number> numbers) { long longSum = 0; double doubleSum = 0d; boolean useDouble = false; for (Number number : numbers) { if (useDouble || number instanceof Double || number instanceof Float) { if (!useDouble) { useDoub...
### Question: BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number avg(Collection<Number> numbers) { Number sum = BluefloodTimerRollup.sum(numbers); if (sum instanceof Long || sum instanceof Integer) return (Long)sum / numbers.size(); else return (Double)sum / (double)numbers.size(); } BluefloodTi...
### Question: BluefloodTimerRollup implements Rollup, IBaseRollup { public static Number max(Collection<Number> numbers) { long longMax = numbers.iterator().next().longValue(); double doubleMax = numbers.iterator().next().doubleValue(); boolean useDouble = false; for (Number number : numbers) { if (useDouble || number ...
### Question: Average extends AbstractRollupStat { public void add(Long input) { count++; final long longAvgUntilNow = toLong(); setLongValue(toLong() + ((input + longRemainder - longAvgUntilNow) / count)); longRemainder = (input + longRemainder - longAvgUntilNow) % count; } Average(); @SuppressWarnings("unused") // us...
### Question: RollupService implements Runnable, RollupServiceMBean { public Collection<Integer> getManagedShards() { return new TreeSet<Integer>(shardStateManager.getManagedShards()); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context, ShardStat...
### Question: BluefloodCounterRollup implements Rollup { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof BluefloodCounterRollup)) return false; BluefloodCounterRollup other = (BluefloodCounterRollup)obj; return this.getCount().equals(other.getCount()) && this.rate == other.rate && this...
### Question: BluefloodCounterRollup implements Rollup { public static BluefloodCounterRollup buildRollupFromRawSamples(Points<SimpleNumber> input) throws IOException { long minTime = Long.MAX_VALUE; long maxTime = Long.MIN_VALUE; BluefloodCounterRollup rollup = new BluefloodCounterRollup(); Number count = 0L; for (Poi...
### Question: BluefloodCounterRollup implements Rollup { public static BluefloodCounterRollup buildRollupFromCounterRollups(Points<BluefloodCounterRollup> input) throws IOException { Number count = 0L; double seconds = 0; int sampleCount = 0; for (Points.Point<BluefloodCounterRollup> point : input.getPoints().values())...
### Question: BluefloodCounterRollup implements Rollup { @Override public RollupType getRollupType() { return RollupType.COUNTER; } BluefloodCounterRollup(); BluefloodCounterRollup withCount(Number count); BluefloodCounterRollup withRate(double rate); BluefloodCounterRollup withSampleCount(int sampleCount); Number getC...
### Question: Event { public Map<String, Object> toMap() { return new HashMap<String, Object>() { { put(FieldLabels.when.name(), getWhen()); put(FieldLabels.what.name(), getWhat()); put(FieldLabels.data.name(), getData()); put(FieldLabels.tags.name(), getTags()); } }; } Event(); @VisibleForTesting Event(long when, Str...
### Question: ElasticTokensIO implements TokenDiscoveryIO { protected String[] getIndexesToSearch() { return new String[] {ELASTICSEARCH_TOKEN_INDEX_NAME_READ}; } ElasticTokensIO(); @Override void insertDiscovery(Token token); @Override void insertDiscovery(List<Token> tokens); @Override List<MetricName> getMetricNames...
### Question: RollupService implements Runnable, RollupServiceMBean { public synchronized Collection<Integer> getRecentlyScheduledShards() { return context.getRecentlyScheduledShards(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context, ShardSta...
### Question: MediaTypeChecker { public boolean isContentTypeValid(HttpHeaders headers) { String contentType = headers.get(HttpHeaders.Names.CONTENT_TYPE); return (Strings.isNullOrEmpty(contentType) || contentType.toLowerCase().contains(MEDIA_TYPE_APPLICATION_JSON)); } boolean isContentTypeValid(HttpHeaders headers); ...
### Question: MediaTypeChecker { public boolean isAcceptValid(HttpHeaders headers) { String accept = headers.get(HttpHeaders.Names.ACCEPT); return ( Strings.isNullOrEmpty(accept) || accept.contains(ACCEPT_ALL) || accept.toLowerCase().contains(MEDIA_TYPE_APPLICATION_JSON)); } boolean isContentTypeValid(HttpHeaders head...
### Question: HttpResponder { public void respond(ChannelHandlerContext ctx, FullHttpRequest req, HttpResponseStatus status) { respond(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, status)); } @VisibleForTesting HttpResponder(); @VisibleForTesting HttpResponder(int httpConnIdleTimeout); static HttpResponder getInst...
### Question: RouteMatcher { public void get(String pattern, HttpRequestHandler handler) { addBinding(pattern, HttpMethod.GET.name(), handler, getBindings); } RouteMatcher(); RouteMatcher withNoRouteHandler(HttpRequestHandler noRouteHandler); void route(ChannelHandlerContext context, FullHttpRequest request); void get(...
### Question: HttpAggregatedMultiIngestionHandler implements HttpRequestHandler { public static List<AggregatedPayload> createBundleList(String json) { Gson gson = new Gson(); JsonParser parser = new JsonParser(); JsonElement element = parser.parse(json); if (!element.isJsonArray()) { throw new InvalidDataException("In...
### Question: SlotStateSerDes { protected static Granularity granularityFromStateCol(String s) { String field = s.split(",", -1)[0]; for (Granularity g : Granularity.granularities()) if (g.name().startsWith(field)) return g; return null; } static SlotState deserialize(String stateStr); String serialize(SlotState state...
### Question: HttpMetricsIndexHandler implements HttpRequestHandler { @Override public void handle(ChannelHandlerContext ctx, FullHttpRequest request) { Tracker.getInstance().track(request); final String tenantId = request.headers().get("tenantId"); HttpRequestWithDecodedQueryParams requestWithParams = (HttpRequestWith...
### Question: HttpMetricNamesHandler implements HttpRequestHandler { @Override public void handle(ChannelHandlerContext ctx, FullHttpRequest request) { Tracker.getInstance().track(request); final Timer.Context httpMetricNamesHandlerTimerContext = HttpMetricNamesHandlerTimer.time(); final String tenantId = request.heade...
### Question: HttpMetricNamesHandler implements HttpRequestHandler { public String getSerializedJSON(final List<MetricName> metricNames) { ArrayNode tokenInfoArrayNode = JsonNodeFactory.instance.arrayNode(); for (MetricName metricName : metricNames) { ObjectNode metricNameInfoNode = JsonNodeFactory.instance.objectNode(...
### Question: HttpEventsQueryHandler implements HttpRequestHandler { @Override public void handle(ChannelHandlerContext ctx, FullHttpRequest request) { Tracker.getInstance().track(request); final String tenantId = request.headers().get("tenantId"); ObjectMapper objectMapper = new ObjectMapper(); String responseBody = n...
### Question: BatchedMetricsJSONOutputSerializer extends JSONBasicRollupsOutputSerializer implements BatchedMetricsOutputSerializer<JSONObject> { @Override public JSONObject transformRollupData(Map<Locator, MetricData> metricData, Set<MetricStat> filterStats) throws SerializationException { final JSONObject globalJSON ...
### Question: DateTimeParser { public static DateTime parse(String dateTimeOffsetString) { String stringToParse = dateTimeOffsetString.replace(" ", "").replace(",", "").replace("_", ""); if (StringUtils.isNumeric(stringToParse) && !isLikelyDateTime(stringToParse)) return dateTimeFromTimestamp(stringToParse); DateTime d...
### Question: Tracker implements TrackerMBean { public synchronized void register() { if (isRegistered) return; try { ObjectName objectName = new ObjectName(trackerName); MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); if (!mBeanServer.isRegistered(objectName)) { ManagementFactory.getPlatformMBean...
### Question: Tracker implements TrackerMBean { public void addTenant(String tenantId) { tenantIds.add(tenantId); log.info("[TRACKER] tenantId " + tenantId + " added."); } private Tracker(); static Tracker getInstance(); synchronized void register(); void addTenant(String tenantId); void removeTenant(String tenantId);...
### Question: Tracker implements TrackerMBean { public void removeTenant(String tenantId) { tenantIds.remove(tenantId); log.info("[TRACKER] tenantId " + tenantId + " removed."); } private Tracker(); static Tracker getInstance(); synchronized void register(); void addTenant(String tenantId); void removeTenant(String te...
### Question: Tracker implements TrackerMBean { public void removeAllMetricNames() { metricNames.clear(); log.info("[TRACKER] All metric names removed."); } private Tracker(); static Tracker getInstance(); synchronized void register(); void addTenant(String tenantId); void removeTenant(String tenantId); void removeAll...
### Question: Tracker implements TrackerMBean { String findTid( String uri ) { Matcher m = patternGetTid.matcher( uri ); if( m.matches() ) return m.group( 1 ); else return null; } private Tracker(); static Tracker getInstance(); synchronized void register(); void addTenant(String tenantId); void removeTenant(String te...
### Question: Tracker implements TrackerMBean { public void setIsTrackingDelayedMetrics() { isTrackingDelayedMetrics = true; log.info("[TRACKER] Tracking delayed metrics started"); } private Tracker(); static Tracker getInstance(); synchronized void register(); void addTenant(String tenantId); void removeTenant(String...
### Question: Tracker implements TrackerMBean { public void trackResponse(HttpRequest request, FullHttpResponse response) { if (request == null) return; if (response == null) return; String tenantId = findTid( request.getUri() ); if (isTracking(tenantId)) { HttpResponseStatus status = response.getStatus(); String messa...
### Question: Tracker implements TrackerMBean { public void trackDelayedMetricsTenant(String tenantid, final List<Metric> delayedMetrics) { if (isTrackingDelayedMetrics) { String logMessage = String.format("[TRACKER][DELAYED METRIC] Tenant sending delayed metrics %s", tenantid); log.info(logMessage); double delayedMinu...
### Question: Tracker implements TrackerMBean { public void trackDelayedAggregatedMetricsTenant(String tenantId, long collectionTimeMs, long delayTimeMs, List<String> delayedMetricNames) { if (isTrackingDelayedMetrics) { String logMessage = String.format("[TRACKER][DELAYED METRIC] Tenant sending delayed metrics %s", te...
### Question: RollupBatchWriter { public synchronized void drainBatch() { List<SingleRollupWriteContext> writeBasicContexts = new ArrayList<SingleRollupWriteContext>(); List<SingleRollupWriteContext> writePreAggrContexts = new ArrayList<SingleRollupWriteContext>(); try { for (int i=0; i<=ROLLUP_BATCH_MAX_SIZE; i++) { S...
### Question: Configuration { private Configuration() { try { init(); } catch (IOException ex) { throw new RuntimeException(ex); } } private Configuration(); static Configuration getInstance(); void loadDefaults(ConfigDefaults[] configDefaults); void init(); Map<Object,Object> getProperties(); Map<Object, Object> getA...
### Question: Configuration { public static List<String> stringListFromString(String value) { List<String> list = Lists.newArrayList(value.split("\\s*,\\s*")); list.removeAll(Arrays.asList("", null)); return list; } private Configuration(); static Configuration getInstance(); void loadDefaults(ConfigDefaults[] configD...
### Question: SlotStateSerDes { protected static int slotFromStateCol(String s) { return Integer.parseInt(s.split(",", -1)[1]); } static SlotState deserialize(String stateStr); String serialize(SlotState state); String serialize(Granularity gran, int slot, UpdateStamp.State state); }### Answer: @Test public void test...
### Question: Configuration { public static boolean booleanFromString(String value) { return "true".equalsIgnoreCase(value); } private Configuration(); static Configuration getInstance(); void loadDefaults(ConfigDefaults[] configDefaults); void init(); Map<Object,Object> getProperties(); Map<Object, Object> getAllProp...
### Question: Configuration { public static int intFromString(String value) { return Integer.parseInt(value); } private Configuration(); static Configuration getInstance(); void loadDefaults(ConfigDefaults[] configDefaults); void init(); Map<Object,Object> getProperties(); Map<Object, Object> getAllProperties(); Strin...
### Question: Configuration { public static long longFromString(String value) { return Long.parseLong(value); } private Configuration(); static Configuration getInstance(); void loadDefaults(ConfigDefaults[] configDefaults); void init(); Map<Object,Object> getProperties(); Map<Object, Object> getAllProperties(); Strin...
### Question: Configuration { public static float floatFromString(String value) { return Float.parseFloat(value); } private Configuration(); static Configuration getInstance(); void loadDefaults(ConfigDefaults[] configDefaults); void init(); Map<Object,Object> getProperties(); Map<Object, Object> getAllProperties(); S...
### Question: SlotStateSerDes { protected static String stateCodeFromStateCol(String s) { return s.split(",", -1)[2]; } static SlotState deserialize(String stateStr); String serialize(SlotState state); String serialize(Granularity gran, int slot, UpdateStamp.State state); }### Answer: @Test public void testStateFromS...
### Question: SlotState { public String toString() { return new StringBuilder().append(granularity == null ? "null" : granularity.name()) .append(",").append(slot) .append(",").append(state == null ? "null" : state.code()) .append(": ").append(getTimestamp() == null ? "" : getTimestamp()) .toString(); } SlotState(Granu...
### Question: SlotState { public SlotState withTimestamp(long timestamp) { this.timestamp = timestamp; return this; } SlotState(Granularity g, int slot, UpdateStamp.State state); SlotState(); SlotState withTimestamp(long timestamp); SlotState withLastUpdatedTimestamp(long lastUpdatedTimestamp); String toString(); bool...
### Question: SlotState { public Granularity getGranularity() { return granularity; } SlotState(Granularity g, int slot, UpdateStamp.State state); SlotState(); SlotState withTimestamp(long timestamp); SlotState withLastUpdatedTimestamp(long lastUpdatedTimestamp); String toString(); boolean equals(Object other); Granul...
### Question: SlotStateSerDes { protected static UpdateStamp.State stateFromCode(String stateCode) { if (stateCode.equals(UpdateStamp.State.Rolled.code())) { return UpdateStamp.State.Rolled; } else { return UpdateStamp.State.Active; } } static SlotState deserialize(String stateStr); String serialize(SlotState state); ...
### Question: BluefloodServiceStarter { public static void validateCassandraHosts() { String hosts = Configuration.getInstance().getStringProperty(CoreConfig.CASSANDRA_HOSTS); if (!(hosts.length() >= 3)) { log.error("No cassandra hosts found in configuration option 'CASSANDRA_HOSTS'"); throw new BluefloodServiceStarter...
### Question: SearchResult { public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj == null) { return false; } else if (!getClass().equals(obj.getClass())) { return false; } return equals((SearchResult) obj); } SearchResult(String tenantId, String name, String unit); String getTenantId(); St...
### Question: RollupBatchWriteRunnable implements Runnable { @Override public void run() { Timer.Context ctx = batchWriteTimer.time(); try { metricsRW.insertRollups(writeContexts); } catch (Exception e) { LOG.warn("not able to insert rollups", e); executionContext.markUnsuccessful(e); } finally { executionContext.decre...
### Question: RetryNTimes implements RetryPolicy { @Override public RetryDecision onReadTimeout(Statement stmnt, ConsistencyLevel cl, int requiredResponses, int receivedResponses, boolean dataReceived, int rTime) { if (dataReceived) { return RetryDecision.ignore(); } else if (rTime < readAttempts) { LOG.info(String.for...
### Question: LocatorFetchRunnable implements Runnable { public void executeRollupForLocator(RollupExecutionContext executionContext, RollupBatchWriter rollupBatchWriter, Locator locator) { executionContext.incrementReadCounter(); final SingleRollupReadContext singleRollupReadContext = new SingleRollupReadContext(locat...
### Question: LocatorFetchRunnable implements Runnable { public int processLocator(int rollCount, RollupExecutionContext executionContext, RollupBatchWriter rollupBatchWriter, Locator locator) { if (log.isTraceEnabled()) log.trace("Rolling up (check,metric,dimension) {} for (gran,slot,shard) {}", locator, parentSlotKey...
### Question: LocatorFetchRunnable implements Runnable { public void finishExecution(long waitStart, RollupExecutionContext executionContext) { if (executionContext.wasSuccessful()) { this.scheduleCtx.clearFromRunning(parentSlotKey); log.info("Successful completion of rollups for (gran,slot,shard) {} in {} ms", new Obj...
### Question: LocatorFetchRunnable implements Runnable { protected RollupExecutionContext createRollupExecutionContext() { return new RollupExecutionContext(Thread.currentThread()); } LocatorFetchRunnable(ScheduleContext scheduleCtx, SlotKey destSlotKey, ExecutorService...
### Question: MavenRepositories { public static List<RemoteRepository> getRemoteRepositories(MavenContainer container, Settings settings) { Set<RemoteRepository> remoteRepos = new HashSet<>(); remoteRepos.addAll(container.getEnabledRepositoriesFromProfile(settings)); String centralRepoURL = getCentralMirrorURL(settings...
### Question: Versions { public static VersionRange parseVersionRange(String range) throws VersionException { Assert.notNull(range, "Version range must not be null."); boolean lowerBoundInclusive = range.startsWith("["); boolean upperBoundInclusive = range.endsWith("]"); String process = range.substring(1, range.length...
### Question: Versions { public static boolean isSnapshot(Version version) { Assert.notNull(version, "Version must not be null."); return version.toString().endsWith(SNAPSHOT_SUFFIX); } static boolean isApiCompatible(Version runtimeVersion, Version addonApiVersion); static VersionRange parseVersionRange(String range);...
### Question: Versions { public static boolean isApiCompatible(Version runtimeVersion, Version addonApiVersion) { if (addonApiVersion == null || addonApiVersion.toString().length() == 0 || runtimeVersion == null || runtimeVersion.toString().length() == 0) return true; int runtimeMajorVersion = runtimeVersion.getMajorVe...
### Question: SingleVersion implements Version { public static final SingleVersion valueOf(String version) { SingleVersion singleVersion = CACHE.get(version); if (singleVersion == null) { singleVersion = new SingleVersion(version); CACHE.put(version, singleVersion); } return singleVersion; } @Deprecated SingleVersion(...
### Question: Arrays { public static <ELEMENTTYPE> ELEMENTTYPE[] removeElementAtIndex(ELEMENTTYPE[] array, int index) { Assert.isTrue(array.length > 0, "Cannot remove an element from an already empty array."); ELEMENTTYPE[] result = java.util.Arrays.copyOf(array, array.length - 1); if (result.length > 0 && array.length...
### Question: ProxyTypeInspector { public static Class<?>[] getCompatibleClassHierarchy(ClassLoader loader, Class<?> origin) { Set<Class<?>> hierarchy = new LinkedHashSet<Class<?>>(); Class<?> baseClass = origin; while (baseClass != null && Modifier.isFinal(baseClass.getModifiers())) { baseClass = baseClass.getSupercla...
### Question: OperatingSystemUtils { public static File createTempDir() throws IllegalStateException { File baseDir = getTempDirectory(); try { return Files.createTempDirectory(baseDir.toPath(), "tmpdir").toFile(); } catch (IOException e) { throw new IllegalStateException("Error while creating temporary directory", e);...
### Question: StateMachine { public void nextCameraState() { switch (cameraState) { case BLOCKED: cameraState = CameraState.BLACK_PICTURE; jsonParser.setCameraState("softBlackPicture"); break; case BLACK_PICTURE: cameraState = CameraState.NEUTRAL_PICTURE; jsonParser.setCameraState("softNeutralPicture"); break; } } Stat...
### Question: StateMachine { public void nextMicrophoneState() { switch (getMicrophoneState()) { case BLOCKED: microphoneState = MicrophoneState.NO_SOUND; jsonParser.setMicrophoneState("softEmptyNoise"); break; case NO_SOUND: microphoneState = MicrophoneState.NEUTRAL_SOUND; jsonParser.setMicrophoneState("softSignalNois...
### Question: ClearanceService { public void cleanDatabase() { Calendar cal = GregorianCalendar.getInstance(Locale.GERMANY); cal.set(Calendar.DATE, cal.get(Calendar.DATE) - (30 * monthsBeforeDeletion)); System.out.println("************************************************"); System.out.println("\t Clearance-Prozess gest...
### Question: Cookie { public static Cookie parse(String setCookie) { return parse(System.currentTimeMillis(), setCookie); } private Cookie(String name, String value, long expiresAt, String domain, String path, boolean secure, boolean httpOnly, boolean hostOnly, boolean persistent); private Cookie(...
### Question: Cookie { @Override public String toString() { StringBuilder result = new StringBuilder(); result.append(name); result.append('='); result.append(value); if (persistent) { if (expiresAt == Long.MIN_VALUE) { result.append("; max-age=0"); } else { result.append("; expires=").append(STANDARD_DATE_FORMAT.forma...
### Question: Cookie { public String getPath() { return path; } private Cookie(String name, String value, long expiresAt, String domain, String path, boolean secure, boolean httpOnly, boolean hostOnly, boolean persistent); private Cookie(Builder builder); String getName(); String getValue(); boolea...
### Question: Cookie { public boolean getSecure() { return secure; } private Cookie(String name, String value, long expiresAt, String domain, String path, boolean secure, boolean httpOnly, boolean hostOnly, boolean persistent); private Cookie(Builder builder); String getName(); String getValue(); b...
### Question: Cookie { public boolean getHttpOnly() { return httpOnly; } private Cookie(String name, String value, long expiresAt, String domain, String path, boolean secure, boolean httpOnly, boolean hostOnly, boolean persistent); private Cookie(Builder builder); String getName(); String getValue(...
### Question: Cookie { public String getDomain() { return domain; } private Cookie(String name, String value, long expiresAt, String domain, String path, boolean secure, boolean httpOnly, boolean hostOnly, boolean persistent); private Cookie(Builder builder); String getName(); String getValue(); bo...
### Question: Cookie { public boolean getPersistent() { return persistent; } private Cookie(String name, String value, long expiresAt, String domain, String path, boolean secure, boolean httpOnly, boolean hostOnly, boolean persistent); private Cookie(Builder builder); String getName(); String getVa...
### Question: Ray2D { public Segment2D intersectionSegment(Ray2D other) { if(this.contains(other.getStart()) && other.contains(this.getStart())) { return new Segment2D(this.getStart(), other.getStart()); } else { return null; } } Ray2D(Vector2D start, Vector2D direction); Vector2D getStart(); void setStart(Vector2D sta...
### Question: Ellipse2D { public Vector2D closestPoint(Vector2D point) { return null; } Ellipse2D(Vector2D center, Vector2D direction, double majorAxis, double minorAxis); Vector2D closestPoint(Vector2D point); Vector2D vectorBetween(Vector2D point); Vector2D normal(Vector2D point); Vector2D getCenter(); void setCenter...
### Question: Ellipse2D { public Vector2D vectorBetween(Vector2D point) { Vector2D closestPoint = closestPoint(point); return point.subtract(closestPoint); } Ellipse2D(Vector2D center, Vector2D direction, double majorAxis, double minorAxis); Vector2D closestPoint(Vector2D point); Vector2D vectorBetween(Vector2D point);...
### Question: Ellipse2D { public Vector2D normal(Vector2D point) { Vector2D pointOnEllipse = closestPoint(point); pointOnEllipse = pointOnEllipse.subtract(this.getCenter()).rotate(-this.getOrientation()); Vector2D normal = new Vector2D(pointOnEllipse.getXComponent() * getMinorAxis()/getMajorAxis(), pointOnEllipse.getYC...
### Question: Rectangle2D extends Geometry2D { @Override public Vector2D vectorBetween(Vector2D point) { return this.rectangleAsSegments().vectorBetween(point); } Rectangle2D(Vector2D center, Vector2D direction, double width, double height); @Override double distanceBetween(Vector2D point); @Override double minimalDist...
### Question: Ray2D { public Vector2D intersectionPoint(Ray2D other) { double dx = other.getStart().getXComponent() - this.getStart().getXComponent(); double dy = other.getStart().getYComponent() - this.getStart().getYComponent(); double det = other.getDirection().getXComponent() * this.getDirection().getYComponent() -...
### Question: Ray2D { public boolean isParallel(Ray2D other) { return this.getDirection().cross(other.getDirection()) == 0; } Ray2D(Vector2D start, Vector2D direction); Vector2D getStart(); void setStart(Vector2D start); Vector2D getDirection(); void setDirection(Vector2D direction); Vector2D intersectionPoint(Ray2D ot...
### Question: Ray2D { public boolean equals(Ray2D other) { return this.getStart().equals(other.getStart()) && this.getDirection().getNormalized().equals(other.getDirection().getNormalized()); } Ray2D(Vector2D start, Vector2D direction); Vector2D getStart(); void setStart(Vector2D start); Vector2D getDirection(); void s...
### Question: Ray2D { public boolean contains(Vector2D point) { Vector2D newNorm = point.subtract(this.getStart()).getNormalized(); double dotProduct = newNorm.dot(this.getDirection().getNormalized()); return Math.abs(1.0 - dotProduct) < EPSILON; } Ray2D(Vector2D start, Vector2D direction); Vector2D getStart(); void se...
### Question: Ray2D { public Ray2D intersectionRay(Ray2D other) { double dotProduct = this.getDirection().getNormalized().dot(other.getDirection().getNormalized()); if(this.contains(other.getStart()) && !other.contains(this.getStart()) && Math.abs(1.0 - dotProduct) < EPSILON) { return new Ray2D(other.getStart(), other....
### Question: OpenAPIStyleValidatorGradlePlugin implements Plugin<Project> { public void apply(Project project) { project.getTasks().register("openAPIStyleValidator", OpenAPIStyleValidatorTask.class); } void apply(Project project); }### Answer: @Test public void pluginRegistersATask() { Project project = ProjectBuild...
### Question: OpenApiSpecStyleValidator { public List<StyleError> validate(ValidatorParameters parameters) { this.parameters = parameters; validateInfo(); validateOperations(); validateModels(); validateNaming(); return errorAggregator.getErrorList(); } OpenApiSpecStyleValidator(OpenAPI openApi); List<StyleError> valid...
### Question: KmlUtil { public static String substituteProperties(String template, KmlPlacemark placemark) { StringBuffer sb = new StringBuffer(); Pattern pattern = Pattern.compile("\\$\\[(.+?)]"); Matcher matcher = pattern.matcher(template); while (matcher.find()) { String property = matcher.group(1); String value = p...
### Question: KmlContainerParser { static KmlContainer createContainer(XmlPullParser parser) throws XmlPullParserException, IOException { return assignPropertiesToContainer(parser); } }### Answer: @Test public void testCreateContainerProperty() throws Exception { XmlPullParser xmlPullParser = createParser("amu_basic...
### Question: KmlLineString extends LineString { public ArrayList<LatLng> getGeometryObject() { List<LatLng> coordinatesList = super.getGeometryObject(); return new ArrayList<>(coordinatesList); } KmlLineString(ArrayList<LatLng> coordinates); KmlLineString(ArrayList<LatLng> coordinates, ArrayList<Double> altitudes); A...
### Question: KmlLineString extends LineString { public ArrayList<Double> getAltitudes() { return mAltitudes; } KmlLineString(ArrayList<LatLng> coordinates); KmlLineString(ArrayList<LatLng> coordinates, ArrayList<Double> altitudes); ArrayList<Double> getAltitudes(); ArrayList<LatLng> getGeometryObject(); }### Answer:...
### Question: KmlFeatureParser { static KmlPlacemark createPlacemark(XmlPullParser parser) throws IOException, XmlPullParserException { String styleId = null; KmlStyle inlineStyle = null; HashMap<String, String> properties = new HashMap<String, String>(); Geometry geometry = null; int eventType = parser.getEventType();...
### Question: KmlTrack extends KmlLineString { public ArrayList<Long> getTimestamps() { return mTimestamps; } KmlTrack(ArrayList<LatLng> coordinates, ArrayList<Double> altitudes, ArrayList<Long> timestamps, HashMap<String, String> properties); ArrayList<Long> getTimestamps(); HashMap<String, String> getProperties(); }...
### Question: MultiGeometry implements Geometry { public String getGeometryType() { return geometryType; } MultiGeometry(List<? extends Geometry> geometries); String getGeometryType(); List<Geometry> getGeometryObject(); void setGeometryType(String type); @Override String toString(); }### Answer: @Test public void tes...
### Question: MultiGeometry implements Geometry { public void setGeometryType(String type) { geometryType = type; } MultiGeometry(List<? extends Geometry> geometries); String getGeometryType(); List<Geometry> getGeometryObject(); void setGeometryType(String type); @Override String toString(); }### Answer: @Test public...