method2testcases
stringlengths
118
3.08k
### Question: RollupEvent { public String getUnit() { return unit; } RollupEvent(Locator loc, Rollup rollup, String unit, String gran, long ts); Rollup getRollup(); Locator getLocator(); String getUnit(); String getGranularityName(); long getTimestamp(); void setUnit(String unit); }### Answer: @Test public void unitGe...
### Question: RollupEvent { public String getGranularityName() { return granularityName; } RollupEvent(Locator loc, Rollup rollup, String unit, String gran, long ts); Rollup getRollup(); Locator getLocator(); String getUnit(); String getGranularityName(); long getTimestamp(); void setUnit(String unit); }### Answer: @T...
### Question: RollupEvent { public long getTimestamp() { return timestamp; } RollupEvent(Locator loc, Rollup rollup, String unit, String gran, long ts); Rollup getRollup(); Locator getLocator(); String getUnit(); String getGranularityName(); long getTimestamp(); void setUnit(String unit); }### Answer: @Test public voi...
### Question: RollupTypeCacher extends FunctionWithThreadPool<MetricsCollection, Void> { @Override public Void apply(final MetricsCollection input) throws Exception { getThreadPool().submit(new Runnable() { @Override public void run() { recordWithTimer(input); } }); return null; } RollupTypeCacher(ThreadPoolExecutor ex...
### Question: TypeAndUnitProcessor extends FunctionWithThreadPool<MetricsCollection, Void> { @Override public Void apply(final MetricsCollection input) throws Exception { getThreadPool().submit(new Callable<MetricsCollection>() { public MetricsCollection call() throws Exception { Collection<IncomingMetricException> pro...
### Question: RollupService implements Runnable, RollupServiceMBean { final void poll() { Timer.Context timer = polltimer.time(); context.scheduleEligibleSlots(rollupDelayMillis, rollupDelayForMetricsWithShortDelay, rollupWaitForMetricsWithLongDelay); timer.stop(); } RollupService(ScheduleContext context); @VisibleForT...
### Question: RollupService implements Runnable, RollupServiceMBean { public synchronized void setServerTime(long millis) { log.info("Manually setting server time to {} {}", millis, new java.util.Date(millis)); context.setCurrentTimeMillis(millis); } RollupService(ScheduleContext context); @VisibleForTesting RollupSer...
### Question: SlotKeySerDes { protected static int slotFromSlotKey(String s) { return Integer.parseInt(s.split(",", -1)[1]); } static SlotKey deserialize(String stateStr); String serialize(SlotKey slotKey); String serialize(Granularity gran, int slot, int shard); }### Answer: @Test public void testSlotFromSlotKey() {...
### Question: RollupService implements Runnable, RollupServiceMBean { public synchronized long getServerTime() { return context.getCurrentTimeMillis(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context, ShardStateManager shardStateManager, ...
### Question: SafetyTtlProvider implements TenantTtlProvider { @Override public Optional<TimeValue> getTTL(String tenantId, Granularity gran, RollupType rollupType) { return getSafeTTL(gran, rollupType); } SafetyTtlProvider(); @Override Optional<TimeValue> getTTL(String tenantId, Granularity gran, RollupType rollupType...
### Question: LocatorCache { public synchronized void setLocatorCurrentInBatchLayer(Locator loc) { getOrCreateInsertedLocatorEntry(loc).setBatchCurrent(); } protected LocatorCache(long expireAfterAccessDuration, TimeUnit expireAfterAccessTimeUnit, long expireAfterWriteDuration, TimeUnit expi...
### Question: LocatorCache { public synchronized boolean isLocatorCurrentInBatchLayer(Locator loc) { LocatorCacheEntry entry = insertedLocators.getIfPresent(loc.toString()); return entry != null && entry.isBatchCurrent(); } protected LocatorCache(long expireAfterAccessDuration, TimeUnit expireAfterAccessTimeUnit, ...
### Question: LocatorCache { public synchronized void setLocatorCurrentInDiscoveryLayer(Locator loc) { getOrCreateInsertedLocatorEntry(loc).setDiscoveryCurrent(); } protected LocatorCache(long expireAfterAccessDuration, TimeUnit expireAfterAccessTimeUnit, long expireAfterWriteDuration, TimeU...
### Question: LocatorCache { public synchronized boolean isLocatorCurrentInDiscoveryLayer(Locator loc) { LocatorCacheEntry entry = insertedLocators.getIfPresent(loc.toString()); return entry != null && entry.isDiscoveryCurrent(); } protected LocatorCache(long expireAfterAccessDuration, TimeUnit expireAfterAccessTimeUn...
### Question: RollupService implements Runnable, RollupServiceMBean { public synchronized boolean getKeepingServerTime() { return keepingServerTime; } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context, ShardStateManager shardStateManager, ...
### Question: ConfigTtlProvider implements TenantTtlProvider { @Override public Optional<TimeValue> getTTL(String tenantId, Granularity gran, RollupType rollupType) { final TimeValue ttl = ttlMapper.get(gran, rollupType); if (ttl == null) { log.trace("No valid TTL entry for granularity: {}, rollup type: {}" + " in conf...
### Question: CombinedTtlProvider implements TenantTtlProvider { @Override public Optional<TimeValue> getTTL(String tenantId, Granularity gran, RollupType rollupType) { Optional<TimeValue> primaryValue = primary.getTTL(tenantId, gran, rollupType); Optional<TimeValue> safetyValue = safety.getTTL(tenantId, gran, rollupTy...
### Question: Metric implements IMetric { public void setTtl(TimeValue ttl) { if (!isValidTTL(ttl.toSeconds())) { throw new InvalidDataException("TTL supplied for metric is invalid. Required: 0 < ttl < " + Integer.MAX_VALUE + ", provided: " + ttl.toSeconds()); } ttlInSeconds = (int) ttl.toSeconds(); } Metric(Locator lo...
### Question: Locator implements Comparable<Locator> { public String toString() { return stringRep; } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locator othe...
### Question: Locator implements Comparable<Locator> { public String getTenantId() { return this.tenantId; } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(Locat...
### Question: Locator implements Comparable<Locator> { public String getMetricName() { return this.metricName; } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String getMetricName(); boolean equals(L...
### Question: RollupService implements Runnable, RollupServiceMBean { public synchronized long getPollerPeriod() { return pollerPeriod; } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context, ShardStateManager shardStateManager, ...
### Question: Locator implements Comparable<Locator> { @Override public int hashCode() { return stringRep == null ? 0 : stringRep.hashCode(); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String toString(); String getTenantId(); String ge...
### Question: Locator implements Comparable<Locator> { @Override public boolean equals(Object obj) { return obj != null && obj instanceof Locator && obj.hashCode() == this.hashCode(); } Locator(); private Locator(String fullyQualifiedMetricName); @Override int hashCode(); @Override boolean equals(Object obj); String t...
### Question: Points { public Class getDataClass() { if (points.size() == 0) throw new IllegalStateException(""); return points.values().iterator().next().data.getClass(); } Points(); void add(Point<T> point); Map<Long, Point<T>> getPoints(); boolean isEmpty(); Class getDataClass(); }### Answer: @Test(expected=Illegal...
### Question: AbstractRollupStat { public boolean isFloatingPoint() { return this.isFloatingPoint; } AbstractRollupStat(); boolean isFloatingPoint(); double toDouble(); long toLong(); @Override boolean equals(Object otherObject); void setLongValue(long value); void setDoubleValue(double value); abstract byte getStatTyp...
### Question: RollupService implements Runnable, RollupServiceMBean { public synchronized int getScheduledSlotCheckCount() { return context.getScheduledCount(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context, ShardStateManager shardStateManag...
### Question: RollupService implements Runnable, RollupServiceMBean { public synchronized int getSlotCheckConcurrency() { return locatorFetchExecutors.getMaximumPoolSize(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context, ShardStateManager sha...
### Question: BasicRollup extends BaseRollup implements IBaseRollup { public static BasicRollup buildRollupFromRawSamples(Points<SimpleNumber> input) throws IOException { final BasicRollup basicRollup = new BasicRollup(); basicRollup.computeFromSimpleMetrics(input); return basicRollup; } BasicRollup(); @Override boolea...
### Question: BasicRollup extends BaseRollup implements IBaseRollup { public static BasicRollup buildRollupFromRollups(Points<BasicRollup> input) throws IOException { final BasicRollup basicRollup = new BasicRollup(); basicRollup.computeFromRollups(input); return basicRollup; } BasicRollup(); @Override boolean equals(O...
### Question: RollupService implements Runnable, RollupServiceMBean { public synchronized void setSlotCheckConcurrency(int i) { locatorFetchExecutors.setCorePoolSize(i); locatorFetchExecutors.setMaximumPoolSize(i); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context, ...
### Question: RollupService implements Runnable, RollupServiceMBean { public synchronized int getRollupConcurrency() { return rollupReadExecutors.getMaximumPoolSize(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context, ShardStateManager shardSta...
### Question: MinValue extends AbstractRollupStat { @Override public byte getStatType() { return Constants.MIN; } MinValue(); @SuppressWarnings("unused") // used by Jackson MinValue(long value); @SuppressWarnings("unused") // used by Jackson MinValue(double value); @Override byte getStatType(); }### Answer: @Test pu...
### Question: RollupService implements Runnable, RollupServiceMBean { public synchronized void setRollupConcurrency(int i) { rollupReadExecutors.setCorePoolSize(i); rollupReadExecutors.setMaximumPoolSize(i); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context, ...
### Question: RollupService implements Runnable, RollupServiceMBean { public synchronized int getQueuedRollupCount() { return rollupReadExecutors.getQueue().size(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context, ShardStateManager shardStateM...
### Question: MaxValue extends AbstractRollupStat { @Override public byte getStatType() { return Constants.MAX; } MaxValue(); @SuppressWarnings("unused") // used by Jackson MaxValue(long value); @SuppressWarnings("unused") // used by Jackson MaxValue(double value); @Override byte getStatType(); }### Answer: @Test pu...
### Question: RollupService implements Runnable, RollupServiceMBean { public synchronized int getInFlightRollupCount() { return rollupReadExecutors.getActiveCount(); } RollupService(ScheduleContext context); @VisibleForTesting RollupService(ScheduleContext context, ShardStateManager shardState...
### 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: 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: 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: 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: 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: 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: 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: 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: 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: LocatorFetchRunnable implements Runnable { public void executeRollupForLocator(RollupExecutionContext executionContext, RollupBatchWriter rollupBatchWriter, Locator locator) { executionContext.incrementReadCounter(); final SingleRollupReadContext singleRollupReadContext = new SingleRollupReadContext(locat...
### Question: LocatorFetchRunnable implements Runnable { protected RollupExecutionContext createRollupExecutionContext() { return new RollupExecutionContext(Thread.currentThread()); } LocatorFetchRunnable(ScheduleContext scheduleCtx, SlotKey destSlotKey, ExecutorService...
### 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: 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: 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: 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: 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: 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: 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: 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...