method2testcases
stringlengths
118
6.63k
### Question: PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public ScheduledThreadPoolExecutor getExecutor() { if (executor == null) { log.warn("ScheduledThreadPoolExecutor was null on request"); } return executor; } PlaylistSubscriberStream(); void setExecutor(ScheduledThreadPoolExecutor executor); ScheduledThreadPoolExecutor getExecutor(); void setBufferCheckInterval(int bufferCheckInterval); void setUnderrunTrigger(int underrunTrigger); void start(); void play(); void pause(int position); void resume(int position); void stop(); void seek(int position); void close(); boolean isPaused(); void addItem(IPlayItem item); void addItem(IPlayItem item, int index); void removeItem(int index); void removeAllItems(); void previousItem(); boolean hasMoreItems(); void nextItem(); void setItem(int index); boolean isRandom(); void setRandom(boolean random); boolean isRewind(); void setRewind(boolean rewind); boolean isRepeat(); void setRepeat(boolean repeat); void receiveVideo(boolean receive); void receiveAudio(boolean receive); void setPlaylistController(IPlaylistController controller); int getItemSize(); int getCurrentItemIndex(); IPlayItem getCurrentItem(); IPlayItem getItem(int index); void setBandwidthController(IBWControlService bwController); @Override void setBandwidthConfigure(IBandwidthConfigure config); void written(Object message); IPlaylistSubscriberStreamStatistics getStatistics(); long getCreationTime(); int getCurrentTimestamp(); long getBytesSent(); double getEstimatedBufferFill(); }### Answer: @Test public void testGetExecutor() { System.out.println("testGetExecutor"); assertTrue(pss.getExecutor() != null); }
### Question: XMLUtils { public static String docToString1(Document dom) { StringWriter sw = new StringWriter(); DOM2Writer.serializeAsXML(dom, sw); return sw.toString(); } static Document stringToDoc(String str); static String docToString(Document dom); static String docToString1(Document dom); static String docToString2(Document domDoc); }### Answer: @Test @Ignore public void testDocToString1() { fail("Not yet implemented"); }
### Question: PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void start() { if (engine == null) { IScope scope = getScope(); if (scope != null) { IContext ctx = scope.getContext(); ISchedulingService schedulingService = (ISchedulingService) ctx.getBean(ISchedulingService.BEAN_NAME); IConsumerService consumerService = (IConsumerService) ctx.getBean(IConsumerService.KEY); IProviderService providerService = (IProviderService) ctx.getBean(IProviderService.BEAN_NAME); engine = new PlayEngine.Builder(this, schedulingService, consumerService, providerService).build(); } else { log.info("Scope was null on start"); } } if (bwController == null) { bwController = (IBWControlService) getScope().getContext().getBean(IBWControlService.KEY); } bwContext = bwController.registerBWControllable(this); engine.setBandwidthController(bwController, bwContext); engine.setBufferCheckInterval(bufferCheckInterval); engine.setUnderrunTrigger(underrunTrigger); engine.start(); notifySubscriberStart(); } PlaylistSubscriberStream(); void setExecutor(ScheduledThreadPoolExecutor executor); ScheduledThreadPoolExecutor getExecutor(); void setBufferCheckInterval(int bufferCheckInterval); void setUnderrunTrigger(int underrunTrigger); void start(); void play(); void pause(int position); void resume(int position); void stop(); void seek(int position); void close(); boolean isPaused(); void addItem(IPlayItem item); void addItem(IPlayItem item, int index); void removeItem(int index); void removeAllItems(); void previousItem(); boolean hasMoreItems(); void nextItem(); void setItem(int index); boolean isRandom(); void setRandom(boolean random); boolean isRewind(); void setRewind(boolean rewind); boolean isRepeat(); void setRepeat(boolean repeat); void receiveVideo(boolean receive); void receiveAudio(boolean receive); void setPlaylistController(IPlaylistController controller); int getItemSize(); int getCurrentItemIndex(); IPlayItem getCurrentItem(); IPlayItem getItem(int index); void setBandwidthController(IBWControlService bwController); @Override void setBandwidthConfigure(IBandwidthConfigure config); void written(Object message); IPlaylistSubscriberStreamStatistics getStatistics(); long getCreationTime(); int getCurrentTimestamp(); long getBytesSent(); double getEstimatedBufferFill(); }### Answer: @Test public void testStart() { System.out.println("testStart"); SimplePlayItem item = new SimplePlayItem(); item.setName("DarkKnight.flv"); pss.addItem(item); pss.start(); }
### Question: PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void play() throws IOException { int count = items.size(); if (count == 0) { return; } if (currentItemIndex == -1) { moveToNext(); } while (count-- > 0) { IPlayItem item = null; read.lock(); try { item = items.get(currentItemIndex); engine.play(item); break; } catch (StreamNotFoundException e) { moveToNext(); if (currentItemIndex == -1) { break; } item = items.get(currentItemIndex); } catch (IllegalStateException e) { break; } finally { read.unlock(); } } } PlaylistSubscriberStream(); void setExecutor(ScheduledThreadPoolExecutor executor); ScheduledThreadPoolExecutor getExecutor(); void setBufferCheckInterval(int bufferCheckInterval); void setUnderrunTrigger(int underrunTrigger); void start(); void play(); void pause(int position); void resume(int position); void stop(); void seek(int position); void close(); boolean isPaused(); void addItem(IPlayItem item); void addItem(IPlayItem item, int index); void removeItem(int index); void removeAllItems(); void previousItem(); boolean hasMoreItems(); void nextItem(); void setItem(int index); boolean isRandom(); void setRandom(boolean random); boolean isRewind(); void setRewind(boolean rewind); boolean isRepeat(); void setRepeat(boolean repeat); void receiveVideo(boolean receive); void receiveAudio(boolean receive); void setPlaylistController(IPlaylistController controller); int getItemSize(); int getCurrentItemIndex(); IPlayItem getCurrentItem(); IPlayItem getItem(int index); void setBandwidthController(IBWControlService bwController); @Override void setBandwidthConfigure(IBandwidthConfigure config); void written(Object message); IPlaylistSubscriberStreamStatistics getStatistics(); long getCreationTime(); int getCurrentTimestamp(); long getBytesSent(); double getEstimatedBufferFill(); }### Answer: @Test public void testPlay() throws Exception { System.out.println("testPlay"); pss.play(); }
### Question: PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void pause(int position) { try { engine.pause(position); } catch (IllegalStateException e) { log.debug("pause caught an IllegalStateException"); } } PlaylistSubscriberStream(); void setExecutor(ScheduledThreadPoolExecutor executor); ScheduledThreadPoolExecutor getExecutor(); void setBufferCheckInterval(int bufferCheckInterval); void setUnderrunTrigger(int underrunTrigger); void start(); void play(); void pause(int position); void resume(int position); void stop(); void seek(int position); void close(); boolean isPaused(); void addItem(IPlayItem item); void addItem(IPlayItem item, int index); void removeItem(int index); void removeAllItems(); void previousItem(); boolean hasMoreItems(); void nextItem(); void setItem(int index); boolean isRandom(); void setRandom(boolean random); boolean isRewind(); void setRewind(boolean rewind); boolean isRepeat(); void setRepeat(boolean repeat); void receiveVideo(boolean receive); void receiveAudio(boolean receive); void setPlaylistController(IPlaylistController controller); int getItemSize(); int getCurrentItemIndex(); IPlayItem getCurrentItem(); IPlayItem getItem(int index); void setBandwidthController(IBWControlService bwController); @Override void setBandwidthConfigure(IBandwidthConfigure config); void written(Object message); IPlaylistSubscriberStreamStatistics getStatistics(); long getCreationTime(); int getCurrentTimestamp(); long getBytesSent(); double getEstimatedBufferFill(); }### Answer: @Test public void testPause() { System.out.println("testPause"); long sent = pss.getBytesSent(); pss.pause((int) sent); }
### Question: PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void resume(int position) { try { engine.resume(position); } catch (IllegalStateException e) { log.debug("resume caught an IllegalStateException"); } } PlaylistSubscriberStream(); void setExecutor(ScheduledThreadPoolExecutor executor); ScheduledThreadPoolExecutor getExecutor(); void setBufferCheckInterval(int bufferCheckInterval); void setUnderrunTrigger(int underrunTrigger); void start(); void play(); void pause(int position); void resume(int position); void stop(); void seek(int position); void close(); boolean isPaused(); void addItem(IPlayItem item); void addItem(IPlayItem item, int index); void removeItem(int index); void removeAllItems(); void previousItem(); boolean hasMoreItems(); void nextItem(); void setItem(int index); boolean isRandom(); void setRandom(boolean random); boolean isRewind(); void setRewind(boolean rewind); boolean isRepeat(); void setRepeat(boolean repeat); void receiveVideo(boolean receive); void receiveAudio(boolean receive); void setPlaylistController(IPlaylistController controller); int getItemSize(); int getCurrentItemIndex(); IPlayItem getCurrentItem(); IPlayItem getItem(int index); void setBandwidthController(IBWControlService bwController); @Override void setBandwidthConfigure(IBandwidthConfigure config); void written(Object message); IPlaylistSubscriberStreamStatistics getStatistics(); long getCreationTime(); int getCurrentTimestamp(); long getBytesSent(); double getEstimatedBufferFill(); }### Answer: @Test public void testResume() { System.out.println("testResume"); long sent = pss.getBytesSent(); pss.resume((int) sent); }
### Question: PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void seek(int position) throws OperationNotSupportedException { try { engine.seek(position); } catch (IllegalStateException e) { log.debug("seek caught an IllegalStateException"); } } PlaylistSubscriberStream(); void setExecutor(ScheduledThreadPoolExecutor executor); ScheduledThreadPoolExecutor getExecutor(); void setBufferCheckInterval(int bufferCheckInterval); void setUnderrunTrigger(int underrunTrigger); void start(); void play(); void pause(int position); void resume(int position); void stop(); void seek(int position); void close(); boolean isPaused(); void addItem(IPlayItem item); void addItem(IPlayItem item, int index); void removeItem(int index); void removeAllItems(); void previousItem(); boolean hasMoreItems(); void nextItem(); void setItem(int index); boolean isRandom(); void setRandom(boolean random); boolean isRewind(); void setRewind(boolean rewind); boolean isRepeat(); void setRepeat(boolean repeat); void receiveVideo(boolean receive); void receiveAudio(boolean receive); void setPlaylistController(IPlaylistController controller); int getItemSize(); int getCurrentItemIndex(); IPlayItem getCurrentItem(); IPlayItem getItem(int index); void setBandwidthController(IBWControlService bwController); @Override void setBandwidthConfigure(IBandwidthConfigure config); void written(Object message); IPlaylistSubscriberStreamStatistics getStatistics(); long getCreationTime(); int getCurrentTimestamp(); long getBytesSent(); double getEstimatedBufferFill(); }### Answer: @Test public void testSeek() { System.out.println("testSeek"); long sent = pss.getBytesSent(); try { pss.seek((int) (sent * 2)); } catch (OperationNotSupportedException e) { e.printStackTrace(); } }
### Question: PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void addItem(IPlayItem item) { write.lock(); try { items.add(item); } finally { write.unlock(); } } PlaylistSubscriberStream(); void setExecutor(ScheduledThreadPoolExecutor executor); ScheduledThreadPoolExecutor getExecutor(); void setBufferCheckInterval(int bufferCheckInterval); void setUnderrunTrigger(int underrunTrigger); void start(); void play(); void pause(int position); void resume(int position); void stop(); void seek(int position); void close(); boolean isPaused(); void addItem(IPlayItem item); void addItem(IPlayItem item, int index); void removeItem(int index); void removeAllItems(); void previousItem(); boolean hasMoreItems(); void nextItem(); void setItem(int index); boolean isRandom(); void setRandom(boolean random); boolean isRewind(); void setRewind(boolean rewind); boolean isRepeat(); void setRepeat(boolean repeat); void receiveVideo(boolean receive); void receiveAudio(boolean receive); void setPlaylistController(IPlaylistController controller); int getItemSize(); int getCurrentItemIndex(); IPlayItem getCurrentItem(); IPlayItem getItem(int index); void setBandwidthController(IBWControlService bwController); @Override void setBandwidthConfigure(IBandwidthConfigure config); void written(Object message); IPlaylistSubscriberStreamStatistics getStatistics(); long getCreationTime(); int getCurrentTimestamp(); long getBytesSent(); double getEstimatedBufferFill(); }### Answer: @Test public void testAddItemIPlayItem() { System.out.println("testAddItemIPlayItem"); SimplePlayItem item = new SimplePlayItem(); item.setName("IronMan.flv"); pss.addItem(item); }
### Question: PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void previousItem() { stop(); moveToPrevious(); if (currentItemIndex == -1) { return; } IPlayItem item = null; int count = items.size(); while (count-- > 0) { read.lock(); try { item = items.get(currentItemIndex); engine.play(item); break; } catch (IOException err) { log.error("Error while starting to play item, moving to previous.", err); moveToPrevious(); if (currentItemIndex == -1) { break; } } catch (StreamNotFoundException e) { moveToPrevious(); if (currentItemIndex == -1) { break; } } catch (IllegalStateException e) { break; } finally { read.unlock(); } } } PlaylistSubscriberStream(); void setExecutor(ScheduledThreadPoolExecutor executor); ScheduledThreadPoolExecutor getExecutor(); void setBufferCheckInterval(int bufferCheckInterval); void setUnderrunTrigger(int underrunTrigger); void start(); void play(); void pause(int position); void resume(int position); void stop(); void seek(int position); void close(); boolean isPaused(); void addItem(IPlayItem item); void addItem(IPlayItem item, int index); void removeItem(int index); void removeAllItems(); void previousItem(); boolean hasMoreItems(); void nextItem(); void setItem(int index); boolean isRandom(); void setRandom(boolean random); boolean isRewind(); void setRewind(boolean rewind); boolean isRepeat(); void setRepeat(boolean repeat); void receiveVideo(boolean receive); void receiveAudio(boolean receive); void setPlaylistController(IPlaylistController controller); int getItemSize(); int getCurrentItemIndex(); IPlayItem getCurrentItem(); IPlayItem getItem(int index); void setBandwidthController(IBWControlService bwController); @Override void setBandwidthConfigure(IBandwidthConfigure config); void written(Object message); IPlaylistSubscriberStreamStatistics getStatistics(); long getCreationTime(); int getCurrentTimestamp(); long getBytesSent(); double getEstimatedBufferFill(); }### Answer: @Test public void testPreviousItem() { log.error("Not yet implemented -- get on that"); }
### Question: PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void nextItem() { moveToNext(); if (currentItemIndex == -1) { return; } IPlayItem item = null; int count = items.size(); while (count-- > 0) { read.lock(); try { item = items.get(currentItemIndex); engine.play(item, false); break; } catch (IOException err) { log.error("Error while starting to play item, moving to next", err); moveToNext(); if (currentItemIndex == -1) { break; } } catch (StreamNotFoundException e) { moveToNext(); if (currentItemIndex == -1) { break; } } catch (IllegalStateException e) { break; } finally { read.unlock(); } } } PlaylistSubscriberStream(); void setExecutor(ScheduledThreadPoolExecutor executor); ScheduledThreadPoolExecutor getExecutor(); void setBufferCheckInterval(int bufferCheckInterval); void setUnderrunTrigger(int underrunTrigger); void start(); void play(); void pause(int position); void resume(int position); void stop(); void seek(int position); void close(); boolean isPaused(); void addItem(IPlayItem item); void addItem(IPlayItem item, int index); void removeItem(int index); void removeAllItems(); void previousItem(); boolean hasMoreItems(); void nextItem(); void setItem(int index); boolean isRandom(); void setRandom(boolean random); boolean isRewind(); void setRewind(boolean rewind); boolean isRepeat(); void setRepeat(boolean repeat); void receiveVideo(boolean receive); void receiveAudio(boolean receive); void setPlaylistController(IPlaylistController controller); int getItemSize(); int getCurrentItemIndex(); IPlayItem getCurrentItem(); IPlayItem getItem(int index); void setBandwidthController(IBWControlService bwController); @Override void setBandwidthConfigure(IBandwidthConfigure config); void written(Object message); IPlaylistSubscriberStreamStatistics getStatistics(); long getCreationTime(); int getCurrentTimestamp(); long getBytesSent(); double getEstimatedBufferFill(); }### Answer: @Test public void testNextItem() { log.error("Not yet implemented -- get on that"); }
### Question: PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void setItem(int index) { if (index < 0 || index >= items.size()) { return; } stop(); currentItemIndex = index; read.lock(); try { IPlayItem item = items.get(currentItemIndex); engine.play(item); } catch (IOException e) { log.error("setItem caught a IOException", e); } catch (StreamNotFoundException e) { log.debug("setItem caught a StreamNotFoundException"); } catch (IllegalStateException e) { log.error("Illegal state exception on playlist item setup", e); } finally { read.unlock(); } } PlaylistSubscriberStream(); void setExecutor(ScheduledThreadPoolExecutor executor); ScheduledThreadPoolExecutor getExecutor(); void setBufferCheckInterval(int bufferCheckInterval); void setUnderrunTrigger(int underrunTrigger); void start(); void play(); void pause(int position); void resume(int position); void stop(); void seek(int position); void close(); boolean isPaused(); void addItem(IPlayItem item); void addItem(IPlayItem item, int index); void removeItem(int index); void removeAllItems(); void previousItem(); boolean hasMoreItems(); void nextItem(); void setItem(int index); boolean isRandom(); void setRandom(boolean random); boolean isRewind(); void setRewind(boolean rewind); boolean isRepeat(); void setRepeat(boolean repeat); void receiveVideo(boolean receive); void receiveAudio(boolean receive); void setPlaylistController(IPlaylistController controller); int getItemSize(); int getCurrentItemIndex(); IPlayItem getCurrentItem(); IPlayItem getItem(int index); void setBandwidthController(IBWControlService bwController); @Override void setBandwidthConfigure(IBandwidthConfigure config); void written(Object message); IPlaylistSubscriberStreamStatistics getStatistics(); long getCreationTime(); int getCurrentTimestamp(); long getBytesSent(); double getEstimatedBufferFill(); }### Answer: @Test public void testSetItem() { log.error("Not yet implemented -- get on that"); }
### Question: PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void stop() { try { engine.stop(); } catch (IllegalStateException e) { log.debug("stop caught an IllegalStateException"); } } PlaylistSubscriberStream(); void setExecutor(ScheduledThreadPoolExecutor executor); ScheduledThreadPoolExecutor getExecutor(); void setBufferCheckInterval(int bufferCheckInterval); void setUnderrunTrigger(int underrunTrigger); void start(); void play(); void pause(int position); void resume(int position); void stop(); void seek(int position); void close(); boolean isPaused(); void addItem(IPlayItem item); void addItem(IPlayItem item, int index); void removeItem(int index); void removeAllItems(); void previousItem(); boolean hasMoreItems(); void nextItem(); void setItem(int index); boolean isRandom(); void setRandom(boolean random); boolean isRewind(); void setRewind(boolean rewind); boolean isRepeat(); void setRepeat(boolean repeat); void receiveVideo(boolean receive); void receiveAudio(boolean receive); void setPlaylistController(IPlaylistController controller); int getItemSize(); int getCurrentItemIndex(); IPlayItem getCurrentItem(); IPlayItem getItem(int index); void setBandwidthController(IBWControlService bwController); @Override void setBandwidthConfigure(IBandwidthConfigure config); void written(Object message); IPlaylistSubscriberStreamStatistics getStatistics(); long getCreationTime(); int getCurrentTimestamp(); long getBytesSent(); double getEstimatedBufferFill(); }### Answer: @Test public void testStop() { System.out.println("testStop"); pss.stop(); }
### Question: XMLUtils { public static String docToString2(Document domDoc) throws IOException { try { TransformerFactory transFact = TransformerFactory.newInstance(); Transformer trans = transFact.newTransformer(); trans.setOutputProperty(OutputKeys.INDENT, "no"); StringWriter sw = new StringWriter(); Result result = new StreamResult(sw); trans.transform(new DOMSource(domDoc), result); return sw.toString(); } catch (Exception ex) { throw new IOException(String.format("Error converting from doc to string %s", ex.getMessage())); } } static Document stringToDoc(String str); static String docToString(Document dom); static String docToString1(Document dom); static String docToString2(Document domDoc); }### Answer: @Test @Ignore public void testDocToString2() { fail("Not yet implemented"); }
### Question: PlaylistSubscriberStream extends AbstractClientStream implements IPlaylistSubscriberStream, IPlaylistSubscriberStreamStatistics { public void close() { engine.close(); bwController.unregisterBWControllable(bwContext); notifySubscriberClose(); } PlaylistSubscriberStream(); void setExecutor(ScheduledThreadPoolExecutor executor); ScheduledThreadPoolExecutor getExecutor(); void setBufferCheckInterval(int bufferCheckInterval); void setUnderrunTrigger(int underrunTrigger); void start(); void play(); void pause(int position); void resume(int position); void stop(); void seek(int position); void close(); boolean isPaused(); void addItem(IPlayItem item); void addItem(IPlayItem item, int index); void removeItem(int index); void removeAllItems(); void previousItem(); boolean hasMoreItems(); void nextItem(); void setItem(int index); boolean isRandom(); void setRandom(boolean random); boolean isRewind(); void setRewind(boolean rewind); boolean isRepeat(); void setRepeat(boolean repeat); void receiveVideo(boolean receive); void receiveAudio(boolean receive); void setPlaylistController(IPlaylistController controller); int getItemSize(); int getCurrentItemIndex(); IPlayItem getCurrentItem(); IPlayItem getItem(int index); void setBandwidthController(IBWControlService bwController); @Override void setBandwidthConfigure(IBandwidthConfigure config); void written(Object message); IPlaylistSubscriberStreamStatistics getStatistics(); long getCreationTime(); int getCurrentTimestamp(); long getBytesSent(); double getEstimatedBufferFill(); }### Answer: @Test public void testClose() { System.out.println("testClose"); pss.close(); }
### Question: Scope extends BasicScope implements IScope, IScopeStatistics, ScopeMBean { public Scope() { this(null); } Scope(); Scope(String name); boolean addChildScope(IBasicScope scope); boolean connect(IConnection conn); boolean connect(IConnection conn, Object[] params); boolean createChildScope(String name); void destroy(); void disconnect(IConnection conn); @Override void dispatchEvent(IEvent event); int getActiveClients(); int getActiveConnections(); int getActiveSubscopes(); IBasicScope getBasicScope(String type, String name); Iterator<String> getBasicScopeNames(String type); ClassLoader getClassLoader(); Set<IClient> getClients(); Collection<Set<IConnection>> getConnections(); IContext getContext(); String getContextPath(); long getCreationTime(); @Override int getDepth(); IScopeHandler getHandler(); int getMaxClients(); int getMaxConnections(); int getMaxSubscopes(); @Override IScope getParent(); @Override String getPath(); Resource getResource(String path); Resource[] getResources(String path); IScope getScope(String name); Iterator<String> getScopeNames(); Object getServiceHandler(String name); @SuppressWarnings("unchecked") Set<String> getServiceHandlerNames(); IScopeStatistics getStatistics(); int getTotalClients(); int getTotalConnections(); int getTotalSubscopes(); @Override boolean handleEvent(IEvent event); boolean hasChildScope(String name); boolean hasChildScope(String type, String name); boolean hasContext(); boolean hasHandler(); @Override boolean hasParent(); void init(); void uninit(); boolean isEnabled(); boolean getEnabled(); boolean isRunning(); boolean getRunning(); @Override Iterator<IBasicScope> iterator(); Set<IConnection> lookupConnections(IClient client); void registerServiceHandler(String name, Object handler); void removeChildScope(IBasicScope scope); void setAutoStart(boolean autoStart); void setChildLoadPath(String pattern); void setContext(IContext context); void setDepth(int depth); void setEnabled(boolean enabled); void setHandler(IScopeHandler handler); @Override void setName(String name); void setParent(IScope parent); void setPersistenceClass(String persistenceClass); boolean start(); void stop(); @Override String toString(); void unregisterServiceHandler(String name); IServer getServer(); void lock(); void unlock(); }### Answer: @Test public void testScope() { if (appScope == null) { appScope = (WebScope) applicationContext.getBean("web.scope"); log.debug("Application / web scope: {}", appScope); } TestCase.assertTrue(appScope.createChildScope("room1")); IScope room1 = appScope.getScope("room1"); log.debug("Room 1: {}", room1); IContext rmCtx1 = room1.getContext(); log.debug("Context 1: {}", rmCtx1); TestCase.assertTrue(room1.createChildScope("room2")); IScope room2 = room1.getScope("room2"); log.debug("Room 2: {}", room2); IContext rmCtx2 = room2.getContext(); log.debug("Context 2: {}", rmCtx2); TestCase.assertTrue(room2.createChildScope("room3")); IScope room3 = room2.getScope("room3"); log.debug("Room 3: {}", room3); IContext rmCtx3 = room3.getContext(); log.debug("Context 3: {}", rmCtx3); TestCase.assertTrue(room1.createChildScope("room4")); IScope room4 = room1.getScope("room4"); log.debug("Room 4: {}", room4); IContext rmCtx4 = room4.getContext(); log.debug("Context 4: {}", rmCtx4); TestCase.assertTrue(room4.createChildScope("room5")); IScope room5 = room4.getScope("room5"); log.debug("Room 5: {}", room5); IContext rmCtx5 = room5.getContext(); log.debug("Context 5: {}", rmCtx5); }
### Question: ExtendedPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer { public Properties getMergedProperties() { return mergedProperties; } Properties getMergedProperties(); void setWildcardLocations( String[] locations ); static synchronized void addGlobalProperty( String key, String val ); }### Answer: @Test public void testLocationsProperty() { ExtendedPropertyPlaceholderConfigurer configurer = (ExtendedPropertyPlaceholderConfigurer)context.getBean( "boringPlaceholderConfig" ); assertEquals( testProperties, configurer.getMergedProperties() ); } @Test public void testWildcardLocationsProperty() { ExtendedPropertyPlaceholderConfigurer configurer = (ExtendedPropertyPlaceholderConfigurer)context.getBean( "wildcard1PlaceholderConfig" ); Properties mergedProp = new Properties(); mergedProp.putAll( testProperties ); mergedProp.putAll( testAProperties ); mergedProp.putAll( testBProperties ); assertEquals( mergedProp, configurer.getMergedProperties() ); configurer = (ExtendedPropertyPlaceholderConfigurer)context.getBean( "wildcard2PlaceholderConfig" ); mergedProp = new Properties(); mergedProp.putAll( testAProperties ); mergedProp.putAll( testBProperties ); mergedProp.putAll( testProperties ); assertEquals( mergedProp, configurer.getMergedProperties() ); } @Test public void testLocationsPropertyOverridesWildcardLocationsProperty() { ExtendedPropertyPlaceholderConfigurer configurer = (ExtendedPropertyPlaceholderConfigurer)context.getBean( "locationsOverridesWildcardLocationsPlaceholderConfig" ); Properties mergedProp = new Properties(); mergedProp.putAll( testProperties ); assertEquals( mergedProp, configurer.getMergedProperties() ); }
### Question: HMAC { public byte[] computeMac() { Mac hm = null; byte[] result = null; if (log.isDebugEnabled()) { log.debug("Key data: {}", byteArrayToHex(keyBytes)); log.debug("Hash data: {}", byteArrayToHex(dataBytes)); log.debug("Algorithm: {}", ALGORITHM_ID); } try { hm = Mac.getInstance(ALGORITHM_ID); Key k1 = new SecretKeySpec(keyBytes, 0, keyBytes.length, ALGORITHM_ID); hm.init(k1); result = hm.doFinal(dataBytes); } catch (Exception e) { log.warn("Bad algorithm or crypto library problem", e); } return result; } static final boolean isHexStringChar(char c); static final boolean isHex(String sampleData); static final boolean isHex(byte[] sampleData, int len); static final byte[] hexToByteArray(String str, boolean rev); static final String byteArrayToHex(byte[] a); byte[] readDataFile(File f, int minValidLength); byte[] readDataStream(InputStream is, int minValidLength); byte[] computeMac(); static final String ALGORITHM_ID; static final int MIN_LENGTH; static final int BUF_LENGTH; }### Answer: @Test public void testHMAC() { HMAC h1 = new HMAC(); assertNotNull(h1); try { Provider sp = new com.sun.crypto.provider.SunJCE(); Security.addProvider(sp); } catch (Exception e) { fail("Problem loading crypto provider" + e); } byte[] hmac = h1.computeMac(); assertNull("Currently HMAC is broken since you can't actually " + "set the keyData or data elements. This test will break once someone fixes that", hmac); }
### Question: JMXAgent implements NotificationListener { public static boolean unregisterMBean(ObjectName oName) { boolean unregistered = false; if (null != oName) { try { if (mbs.isRegistered(oName)) { log.debug("Mbean is registered"); mbs.unregisterMBean(oName); unregistered = !mbs.isRegistered(oName); } else { log.debug("Mbean is not currently registered"); } } catch (Exception e) { log.warn("Exception unregistering mbean {}", e); } } log.debug("leaving unregisterMBean..."); return unregistered; } static String trimClassName(String className); @SuppressWarnings("unchecked") static boolean registerMBean(Object instance, String className, Class interfaceClass); @SuppressWarnings("unchecked") static boolean registerMBean(Object instance, String className, Class interfaceClass, ObjectName name); @SuppressWarnings("unchecked") static boolean registerMBean(Object instance, String className, Class interfaceClass, String name); static void shutdown(); static boolean unregisterMBean(ObjectName oName); static boolean updateMBeanAttribute(ObjectName oName, String key, int value); static boolean updateMBeanAttribute(ObjectName oName, String key, String value); void handleNotification(Notification notification, Object handback); void init(); void setEnableRmiAdapter(boolean enableRmiAdapter); void setEnableRmiAdapter(String enableRmiAdapterString); void setEnableSsl(boolean enableSsl); void setEnableSsl(String enableSslString); void setRemoteAccessProperties(String remoteAccessProperties); void setRemotePasswordProperties(String remotePasswordProperties); void setRemoteSSLKeystore(String remoteSSLKeystore); void setRemoteSSLKeystorePass(String remoteSSLKeystorePass); void setRmiAdapterRemotePort(String rmiAdapterRemotePort); void setRmiAdapterPort(String rmiAdapterPort); void setRmiAdapterHost(String rmiAdapterHost); void setStartRegistry(boolean startRegistry); void setEnableMinaMonitor(boolean enableMinaMonitor); void setEnableMinaMonitor(String enableMinaMonitor); static boolean isEnableMinaMonitor(); }### Answer: @Test public void testUnregisterMBean() throws Exception { logger.info("Default jmx domain: {}", JMXFactory.getDefaultDomain()); JMXAgent agent = new JMXAgent(); agent.init(); MBeanServer mbs = JMXFactory.getMBeanServer(); ObjectName oName = JMXFactory.createMBean( "org.red5.server.net.rtmp.RTMPMinaConnection", "connectionType=persistent,host=10.0.0.1,port=1935,clientId=1"); assertNotNull(oName); ObjectName oName2 = new ObjectName( "org.red5.server:type=RTMPMinaConnection,connectionType=persistent,host=10.0.0.2,port=1935,clientId=2"); logger.info("Register check 1: {}", mbs.isRegistered(oName)); assertTrue(JMXAgent.unregisterMBean(oName)); logger.info("Register check 2: {}", mbs.isRegistered(oName)); assertFalse(JMXAgent.unregisterMBean(oName)); logger.info("Register check 3: {}", mbs.isRegistered(oName2)); assertFalse(JMXAgent.unregisterMBean(oName2)); }
### Question: JMXFactory { public static ObjectName createMBean(String className, String attributes) { log.info("Create the {} MBean within the MBeanServer", className); ObjectName objectName = null; try { StringBuilder objectNameStr = new StringBuilder(domain); objectNameStr.append(":type="); objectNameStr.append(className .substring(className.lastIndexOf(".") + 1)); objectNameStr.append(","); objectNameStr.append(attributes); log.info("ObjectName = {}", objectNameStr); objectName = new ObjectName(objectNameStr.toString()); if (!mbs.isRegistered(objectName)) { mbs.createMBean(className, objectName); } else { log.debug("MBean has already been created: {}", objectName); } } catch (Exception e) { log.error("Could not create the {} MBean. {}", className, e); } return objectName; } static ObjectName createMBean(String className, String attributes); static ObjectName createObjectName(String... strings); static ObjectName createSimpleMBean(String className, String objectNameStr); static String getDefaultDomain(); static MBeanServer getMBeanServer(); @SuppressWarnings("unchecked") static boolean registerNewMBean(String className, Class interfaceClass); @SuppressWarnings("unchecked") static boolean registerNewMBean(String className, Class interfaceClass, ObjectName name); @SuppressWarnings("unchecked") static boolean registerNewMBean(String className, Class interfaceClass, String name); String getDomain(); void setDomain(String domain); }### Answer: @Test public void testCreateMBean() { ObjectName objectName = null; try { objectName = JMXFactory.createMBean( "org.red5.server.jmx.JMXFactoryTest", "test=1"); assertNotNull(objectName); objectName = JMXFactory.createMBean( "org.red5.server.jmx.JMXFactoryTest", "test=2"); assertNotNull(objectName); objectName = JMXFactory.createMBean( "org.red5.server.jmx.JMXFactoryTest", "test=1"); assertNotNull(objectName); } catch (Exception e) { fail("Exception occured"); } }
### Question: JMXFactory { public static ObjectName createSimpleMBean(String className, String objectNameStr) { log.info("Create the {} MBean within the MBeanServer", className); log.info("ObjectName = {}", objectNameStr); try { ObjectName objectName = ObjectName.getInstance(objectNameStr); if (!mbs.isRegistered(objectName)) { mbs.createMBean(className, objectName); } else { log.debug("MBean has already been created: {}", objectName); } return objectName; } catch (Exception e) { log.error("Could not create the {} MBean. {}", className, e); } return null; } static ObjectName createMBean(String className, String attributes); static ObjectName createObjectName(String... strings); static ObjectName createSimpleMBean(String className, String objectNameStr); static String getDefaultDomain(); static MBeanServer getMBeanServer(); @SuppressWarnings("unchecked") static boolean registerNewMBean(String className, Class interfaceClass); @SuppressWarnings("unchecked") static boolean registerNewMBean(String className, Class interfaceClass, ObjectName name); @SuppressWarnings("unchecked") static boolean registerNewMBean(String className, Class interfaceClass, String name); String getDomain(); void setDomain(String domain); }### Answer: @Test public void testCreateSimpleMBean() { System.out.println("Not yet implemented"); }
### Question: JMXFactory { public static String getDefaultDomain() { return domain; } static ObjectName createMBean(String className, String attributes); static ObjectName createObjectName(String... strings); static ObjectName createSimpleMBean(String className, String objectNameStr); static String getDefaultDomain(); static MBeanServer getMBeanServer(); @SuppressWarnings("unchecked") static boolean registerNewMBean(String className, Class interfaceClass); @SuppressWarnings("unchecked") static boolean registerNewMBean(String className, Class interfaceClass, ObjectName name); @SuppressWarnings("unchecked") static boolean registerNewMBean(String className, Class interfaceClass, String name); String getDomain(); void setDomain(String domain); }### Answer: @Test public void testGetDefaultDomain() { System.out.println("Not yet implemented"); }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { public static PhysicsUnit<?> valueOf(CharSequence charSequence) { return UCUMFormat.getCaseSensitiveInstance().parse(charSequence, new ParsePosition(0)); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testValueOf() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final UnitConverter getConverterToAny(Unit<?> that) throws IncommensurableException, UnconvertibleException { if (!isCompatible(that)) throw new IncommensurableException(this + " is not compatible with " + that); PhysicsUnit thatPhysics = (PhysicsUnit)that; DimensionalModel model = DimensionalModel.getCurrent(); PhysicsUnit thisSystemUnit = this.getSystemUnit(); UnitConverter thisToDimension = model.getDimensionalTransform(thisSystemUnit.getDimension()).concatenate(this.getConverterToSI()); PhysicsUnit thatSystemUnit = thatPhysics.getSystemUnit(); UnitConverter thatToDimension = model.getDimensionalTransform(thatSystemUnit.getDimension()).concatenate(thatPhysics.getConverterToSI()); return thatToDimension.inverse().concatenate(thisToDimension); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testGetConverterToAny() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final PhysicsUnit<?> alternate(String symbol) { return new AlternateUnit(this, symbol); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testAlternate() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final PhysicsUnit<Q> transform(UnitConverter operation) { PhysicsUnit<Q> systemUnit = this.getSystemUnit(); UnitConverter cvtr = this.getConverterToSI().concatenate(operation); if (cvtr.equals(PhysicsConverter.IDENTITY)) return systemUnit; return new TransformedUnit<Q>(systemUnit, cvtr); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testTransform() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final PhysicsUnit<Q> add(double offset) { if (offset == 0) return this; return transform(new AddConverter(offset)); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testAdd() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final PhysicsUnit<?> inverse() { if (this.equals(SI.ONE)) return this; return ProductUnit.getQuotientInstance(SI.ONE, this); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testInverse() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final PhysicsUnit<?> root(int n) { if (n > 0) return ProductUnit.getRootInstance(this, n); else if (n == 0) throw new ArithmeticException("Root's order of zero"); else return SI.ONE.divide(this.root(-n)); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testRoot() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final PhysicsUnit<?> pow(int n) { if (n > 0) return this.multiply(this.pow(n - 1)); else if (n == 0) return SI.ONE; else return SI.ONE.divide(this.pow(-n)); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testPow() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public abstract int hashCode(); protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testHashCode() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public abstract boolean equals(Object that); protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testEquals() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { public AnnotatedUnit<Q> annotate(String annotation) { return new AnnotatedUnit<Q>(this, annotation); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testAnnotate() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public String toString() { TextBuilder tmp = TextBuilder.newInstance(); try { return UCUMFormat.getCaseSensitiveInstance().format(this, tmp).toString(); } catch (IOException ioException) { throw new Error(ioException); } finally { TextBuilder.recycle(tmp); } } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testToString() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public String getSymbol() { return null; } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testGetSymbol() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final PhysicsUnit<Q> getSystemUnit() { return toSI(); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testGetSystemUnit() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testGetProductUnits() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public abstract PhysicsDimension getDimension(); protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testGetDimension() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final boolean isCompatible(Unit<?> that) { if ((this == that) || this.equals(that)) return true; if (!(that instanceof PhysicsUnit)) return false; PhysicsDimension thisDimension = this.getDimension(); PhysicsDimension thatDimension = ((PhysicsUnit)that).getDimension(); if (thisDimension.equals(thatDimension)) return true; DimensionalModel model = DimensionalModel.getCurrent(); return model.getFundamentalDimension(thisDimension).equals(model.getFundamentalDimension(thatDimension)); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testIsCompatible() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final <T extends Quantity<T>> PhysicsUnit<T> asType(Class<T> type) { PhysicsDimension typeDimension = PhysicsDimension.getDimension(type); if ((typeDimension != null) && (!this.getDimension().equals(typeDimension))) throw new ClassCastException("The unit: " + this + " is not compatible with quantities of type " + type); return (PhysicsUnit<T>) this; } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testAsType() { }
### Question: PhysicsUnit implements Unit<Q>, XMLSerializable { @Override public final UnitConverter getConverterTo(Unit<Q> that) throws UnconvertibleException { if ((this == that) || this.equals(that)) return PhysicsConverter.IDENTITY; Unit<Q> thisSystemUnit = this.getSystemUnit(); Unit<Q> thatSystemUnit = that.getSystemUnit(); if (!thisSystemUnit.equals(thatSystemUnit)) return getConverterToAny(that); UnitConverter thisToSI= this.getConverterToSI(); UnitConverter thatToSI= that.getConverterTo(thatSystemUnit); return thatToSI.inverse().concatenate(thisToSI); } protected PhysicsUnit(); boolean isSI(); abstract PhysicsUnit<Q> toSI(); abstract UnitConverter getConverterToSI(); AnnotatedUnit<Q> annotate(String annotation); static PhysicsUnit<?> valueOf(CharSequence charSequence); @Override String toString(); @Override final PhysicsUnit<Q> getSystemUnit(); @Override final boolean isCompatible(Unit<?> that); @Override final PhysicsUnit<T> asType(Class<T> type); @Override String getSymbol(); @Override abstract Map<? extends PhysicsUnit, Integer> getProductUnits(); @Override abstract PhysicsDimension getDimension(); @Override final UnitConverter getConverterTo(Unit<Q> that); @Override final UnitConverter getConverterToAny(Unit<?> that); @Override final PhysicsUnit<?> alternate(String symbol); @Override final PhysicsUnit<Q> transform(UnitConverter operation); @Override final PhysicsUnit<Q> add(double offset); @Override final PhysicsUnit<Q> multiply(double factor); @Override final Unit<?> multiply(Unit<?> that); final PhysicsUnit<?> multiply(PhysicsUnit<?> that); @Override final PhysicsUnit<?> inverse(); @Override final PhysicsUnit<Q> divide(double divisor); @Override final Unit<?> divide(Unit<?> that); final PhysicsUnit<?> divide(PhysicsUnit<?> that); @Override final PhysicsUnit<?> root(int n); @Override final PhysicsUnit<?> pow(int n); @Override abstract int hashCode(); @Override abstract boolean equals(Object that); }### Answer: @Test public void testGetConverterTo() { }
### Question: SpansToDependencyLinks implements Function<Iterable<Span>, Iterable<Dependency>> { protected Optional<Dependency> sharedSpanDependency(Set<Span> sharedSpans) { String clientService = null; String serverService = null; for (Span span: sharedSpans) { for (KeyValue tag: span.getTags()) { if (Tags.SPAN_KIND_CLIENT.equals(tag.getValueString()) || Tags.SPAN_KIND_PRODUCER.equals(tag.getValueString())) { clientService = span.getProcess().getServiceName(); } else if (Tags.SPAN_KIND_SERVER.equals(tag.getValueString()) || Tags.SPAN_KIND_CONSUMER.equals(tag.getValueString())) { serverService = span.getProcess().getServiceName(); } if (clientService != null && serverService != null) { return Optional.of(new Dependency(clientService, serverService)); } } } return Optional.empty(); } SpansToDependencyLinks(String peerServiceTag); @Override Iterable<Dependency> call(Iterable<Span> trace); public String peerServiceTag; }### Answer: @Test public void shouldReturnDependencyWithClientAndServerSpans() { SpansToDependencyLinks spansToDependencyLinks = new SpansToDependencyLinks(""); Set<Span> sharedSpans = new HashSet<>(); sharedSpans.add(createSpan("clientName", Tags.SPAN_KIND_CLIENT)); sharedSpans.add(createSpan("serverName", Tags.SPAN_KIND_SERVER)); Optional<Dependency> result = spansToDependencyLinks.sharedSpanDependency(sharedSpans); assertTrue(result.isPresent()); assertEquals(new Dependency("clientName", "serverName"), result.get()); } @Test public void shouldReturnDependencyWithConsumerAndProducer() { SpansToDependencyLinks spansToDependencyLinks = new SpansToDependencyLinks(""); Set<Span> sharedSpans = new HashSet<>(); sharedSpans.add(createSpan("consumerName", Tags.SPAN_KIND_CONSUMER)); sharedSpans.add(createSpan("producerName", Tags.SPAN_KIND_PRODUCER)); Optional<Dependency> result = spansToDependencyLinks.sharedSpanDependency(sharedSpans); assertTrue(result.isPresent()); assertEquals(new Dependency("producerName", "consumerName"), result.get()); } @Test public void shouldReturnEmptyDependencyForSpansWithoutSpanKindDefinition() { SpansToDependencyLinks spansToDependencyLinks = new SpansToDependencyLinks(""); Set<Span> sharedSpans = new HashSet<>(); sharedSpans.add(createSpan("consumerName", "tag")); sharedSpans.add(createSpan("producerName", "tag")); Optional<Dependency> result = spansToDependencyLinks.sharedSpanDependency(sharedSpans); assertFalse(result.isPresent()); }
### Question: DirectSerializationMetadata { public static SerializationMetadata extractMetadata(List<Field> fields) { if (fields.isEmpty()) return EmptyObjectMetadata; Offsets offsets = minMaxOffsets(fields); long totalSize = OBJECT_HEADER_SIZE + offsets.max - offsets.min + 1; return new SerializationMetadata(offsets.min, padToObjectAlignment(totalSize) - OBJECT_HEADER_SIZE); } static SerializationMetadata extractMetadata(List<Field> fields); static SerializationMetadata extractMetadataForPartialCopy(List<Field> fields); }### Answer: @Test public void primitives1Metadata() { unsafeClassHeaderSize64BitCompressedOops(new Primitives1()); SerializationMetadata serializationMetadata = extractMetadata(Introspect.fields(Primitives1.class)); assertEquals(OBJECT_HEADER_SIZE, serializationMetadata.start); assertEquals(4, serializationMetadata.length); } @Test public void primitives2Metadata() { unsafeClassHeaderSize64BitCompressedOops(new Primitives2()); SerializationMetadata serializationMetadata = extractMetadata(Introspect.fields(Primitives2.class)); assertEquals(OBJECT_HEADER_SIZE, serializationMetadata.start); assertEquals(12, serializationMetadata.length); } @Test public void primitives3Metadata() { unsafeClassHeaderSize64BitCompressedOops(new Primitives3()); SerializationMetadata serializationMetadata = extractMetadata(Introspect.fields(Primitives3.class)); assertEquals(OBJECT_HEADER_SIZE, serializationMetadata.start); assertEquals(12, serializationMetadata.length); } @Test public void primitives4Metadata() { unsafeClassHeaderSize64BitCompressedOops(new Primitives4()); SerializationMetadata serializationMetadata = extractMetadata(Introspect.fields(Primitives4.class)); assertEquals(OBJECT_HEADER_SIZE, serializationMetadata.start); assertEquals(4, serializationMetadata.length); } @Test public void primitives5Metadata() { unsafeClassHeaderSize64BitCompressedOops(new Primitives5()); SerializationMetadata serializationMetadata = extractMetadata(Introspect.fields(Primitives5.class)); assertEquals(OBJECT_HEADER_SIZE, serializationMetadata.start); assertEquals(12, serializationMetadata.length); } @Test public void primitives6Metadata() { unsafeClassHeaderSize64BitCompressedOops(new Primitives6()); SerializationMetadata serializationMetadata = extractMetadata(Introspect.fields(Primitives6.class)); assertEquals(OBJECT_HEADER_SIZE, serializationMetadata.start); assertEquals(28, serializationMetadata.length); }
### Question: DirectSerializationFilter { public static List<Field> stopAtFirstIneligibleField(List<Field> fields) { ArrayList<Field> eligibleFields = new ArrayList<Field>(); for (Field f : fields) { if (checkEligible(f)) { eligibleFields.add(f); } else { break; } } return eligibleFields.isEmpty() ? Collections.<Field>emptyList() : eligibleFields; } static List<Field> stopAtFirstIneligibleField(List<Field> fields); }### Answer: @Test public void staticPrimitivesAreNotEligible() { List<Field> field = fieldsNamed("staticIntField"); assertTrue(stopAtFirstIneligibleField(field).isEmpty()); } @Test public void staticPrimitiveArraysAreNotEligible() { List<Field> field = fieldsNamed("staticDoubleArray"); assertTrue(stopAtFirstIneligibleField(field).isEmpty()); } @Test public void staticReferencesAreNotEligible() { List<Field> field = fieldsNamed("staticStringList"); assertTrue(stopAtFirstIneligibleField(field).isEmpty()); } @Test public void staticReferenceArraysAreNotEligible() { List<Field> field = fieldsNamed("staticObjectArray"); assertTrue(stopAtFirstIneligibleField(field).isEmpty()); } @Test public void transientPrimitivesAreNotEligible() { List<Field> field = fieldsNamed("transientShort"); assertTrue(stopAtFirstIneligibleField(field).isEmpty()); } @Test public void transientReferencsAreNotEligible() { List<Field> field = fieldsNamed("transientObject"); assertTrue(stopAtFirstIneligibleField(field).isEmpty()); } @Test public void includesAllEligibleFields() { List<Field> fields = fieldsNamed("intField", "shortField", "longField", "byteField", "stringList"); List<Field> expectedfields = fields.subList(0, 4); assertEquals(expectedfields, stopAtFirstIneligibleField(fields)); } @Test public void instancePrimitivesAreEligible() { List<Field> field = fieldsNamed("intField"); assertEquals(field, stopAtFirstIneligibleField(field)); } @Test public void instancePrimitiveArraysAreNotEligible() { List<Field> field = fieldsNamed("doubleArray"); assertTrue(stopAtFirstIneligibleField(field).isEmpty()); } @Test public void instanceReferencesAreNotEligible() { List<Field> field = fieldsNamed("stringList"); assertTrue(stopAtFirstIneligibleField(field).isEmpty()); } @Test public void instanceReferenceArraysAreNotEligible() { List<Field> field = fieldsNamed("objectArray"); assertTrue(stopAtFirstIneligibleField(field).isEmpty()); }
### Question: RawCopier { public static <T> RawCopier<T> copies(Class<T> tClass) { return new RawCopier<T>(tClass); } private RawCopier(Class<T> tClass); static RawCopier<T> copies(Class<T> tClass); int start(); int end(); void toBytes(Object obj, Bytes bytes); void fromBytes(Bytes bytes, Object obj); void copy(T from, T to); }### Answer: @Test public void testStartEnd() { RawCopier<A> aRawCopier = RawCopier.copies(A.class); if (aRawCopier.start != 8) assertEquals(12, aRawCopier.start); assertEquals(aRawCopier.start + 3 * 4, aRawCopier.end); RawCopier<B> bRawCopier = RawCopier.copies(B.class); if (aRawCopier.start != 8) assertEquals(16, bRawCopier.start); assertEquals(bRawCopier.start + 4 * 8, bRawCopier.end); }
### Question: ResizeableMappedStore extends AbstractMappedStore { public void resize(long newSize) throws IOException { validateSize(newSize); unmapAndSyncToDisk(); resizeIfNeeded(0L, newSize); this.mmapInfoHolder.setSize(newSize); map(0L); } ResizeableMappedStore(File file, FileChannel.MapMode mode, long size); ResizeableMappedStore(File file, FileChannel.MapMode mode, long size, ObjectSerializer objectSerializer); void resize(long newSize); }### Answer: @Test public void testResizableMappedStore() throws IOException { File file = MappedStoreTest.getStoreFile("resizable-mapped-store.tmp"); final int smallSize = 1024, largeSize = 10 * smallSize; { ResizeableMappedStore ms = new ResizeableMappedStore(file, FileChannel.MapMode.READ_WRITE, smallSize); DirectBytes slice1 = ms.bytes(); for (int i = 0; i < smallSize; ++i) { slice1.writeByte(42); } ms.resize(largeSize); DirectBytes slice2 = ms.bytes(); slice2.skipBytes(smallSize); for (int i = smallSize; i < largeSize; ++i) { slice2.writeByte(24); } ms.close(); } assertEquals(largeSize, file.length()); { ResizeableMappedStore ms = new ResizeableMappedStore(file, FileChannel.MapMode.READ_WRITE, file.length()); DirectBytes slice = ms.bytes(); assertEquals(42, slice.readByte(smallSize - 1)); assertEquals(24, slice.readByte(largeSize - 1)); slice.release(); ms.close(); } }
### Question: VanillaMappedFile implements VanillaMappedResource { @Override public synchronized void close() throws IOException { if (this.fileChannel.isOpen()) { long start = System.nanoTime(); this.fileChannel.close(); this.fileLifecycleListener.onEvent(EventType.CLOSE, this.path, System.nanoTime() - start); } } VanillaMappedFile(final File path, VanillaMappedMode mode); VanillaMappedFile(final File path, VanillaMappedMode mode, long size, FileLifecycleListener fileLifecycleListener); static VanillaMappedFile readWrite(final File path); static VanillaMappedFile readWrite(final File path, long size); static VanillaMappedFile readOnly(final File path); static VanillaMappedFile readOnly(final File path, long size); static VanillaMappedBytes readWriteBytes(final File path, long size); static VanillaMappedBytes readWriteBytes(final File path, long size, long index); static VanillaMappedBytes readWriteBytes(final File path, long size, long index, FileLifecycleListener fileLifecycleListener); VanillaMappedBytes bytes(long address, long size); VanillaMappedBytes bytes(long address, long size, long index); @Override String path(); @Override long size(); @Override synchronized void close(); }### Answer: @Test public void testMappedCache3() throws IOException { VanillaMappedCache<Integer> cache = new VanillaMappedCache(32, false); VanillaMappedBytes buffer = null; File file = null; for (int j = 0; j < 5; j++) { long start = System.nanoTime(); int maxRuns = 10000, runs; for (runs = 0; runs < maxRuns; runs++) { file = newTempraryFile("vmc-3-v" + runs, false); buffer = cache.put(runs, file, 256, runs); buffer.writeLong(0, 0x12345678); assertEquals(0x12345678L, buffer.readLong(0)); assertEquals(runs, buffer.index()); buffer.release(); buffer.close(); assertEquals(0, buffer.refCount()); assertTrue(file.delete()); if (System.nanoTime() - start > 1e9) break; } long time = System.nanoTime() - start; System.out.printf("The average time was %,d us%n", time / runs / 1000); } cache.close(); } @Test public void testMappedCache4() throws IOException { VanillaMappedCache<Integer> cache = new VanillaMappedCache(10000, true); VanillaMappedBytes buffer = cache.put(1, newTempraryFile("vmc-4"), 256, 1); buffer.reserve(); assertEquals(2, buffer.refCount()); buffer.release(); assertEquals(1, buffer.refCount()); cache.close(); assertEquals(0, buffer.refCount()); }
### Question: DataValueGenerator { public String generateNativeObject(Class<?> tClass) { return generateNativeObject(DataValueModels.acquireModel(tClass)); } static Class firstPrimitiveFieldType(Class valueClass); static String bytesType(Class type); static String simpleName(Class<?> type); static CharSequence normalize(Class aClass); static Method getGetter(FieldModel model); static Method getVolatileGetter(FieldModel model); static Method getSetter(FieldModel model); static Method getOrderedSetter(FieldModel model); static void appendImported(SortedSet<Class> imported, StringBuilder sb); static void appendPackage(DataValueModel<?> dvmodel, StringBuilder sb); static String getPackage(DataValueModel<?> dvmodel); static int fieldSize(FieldModel model); static TreeSet<Class> newImported(); static boolean shouldImport(Class type); static Map.Entry<String, FieldModel>[] heapSizeOrderedFieldsGrouped(DataValueModel<?> dvmodel); static int computeOffset(int offset, FieldModel model); static int computeNonScalarOffset(DataValueModel dvmodel, Class type); T heapInstance(Class<T> tClass); Class acquireHeapClass(Class<T> tClass); T nativeInstance(Class<T> tClass); Class acquireNativeClass(Class<T> tClass); String generateNativeObject(Class<?> tClass); String generateNativeObject(DataValueModel<?> dvmodel); boolean isDumpCode(); void setDumpCode(boolean dumpCode); }### Answer: @Test public void testGenerateNativeWithGetUsing() throws ClassNotFoundException, IllegalAccessException, InstantiationException { String actual = new DataValueGenerator().generateNativeObject(JavaBeanInterfaceGetUsing.class); System.out.println(actual); CachedCompiler cc = new CachedCompiler(null, null); Class aClass = cc.loadFromJava(JavaBeanInterfaceGetUsing.class.getName() + "$$Native", actual); JavaBeanInterfaceGetUsing jbi = (JavaBeanInterfaceGetUsing) aClass.asSubclass(JavaBeanInterfaceGetUsing.class).newInstance(); Bytes bytes = ByteBufferBytes.wrap(ByteBuffer.allocate(64)); ((Byteable) jbi).bytes(bytes, 0L); jbi.setString("G'day"); assertEquals("G'day", jbi.getUsingString(new StringBuilder()).toString()); } @Test public void testGenerateNativeWithHasArrays() throws ClassNotFoundException, IllegalAccessException, InstantiationException { String actual = new DataValueGenerator().generateNativeObject(HasArraysInterface.class); System.out.println(actual); CachedCompiler cc = new CachedCompiler(null, null); Class aClass = cc.loadFromJava(HasArraysInterface.class.getName() + "$$Native", actual); HasArraysInterface hai = (HasArraysInterface) aClass.asSubclass(HasArraysInterface.class).newInstance(); Bytes bytes = ByteBufferBytes.wrap(ByteBuffer.allocate(152)); ((Byteable) hai).bytes(bytes, 0L); hai.setStringAt(0, "G'day"); assertEquals("G'day", hai.getStringAt(0)); }
### Question: DataValueGenerator { public <T> T nativeInstance(Class<T> tClass) { try { return (T) acquireNativeClass(tClass).newInstance(); } catch (Exception e) { throw new AssertionError(e); } } static Class firstPrimitiveFieldType(Class valueClass); static String bytesType(Class type); static String simpleName(Class<?> type); static CharSequence normalize(Class aClass); static Method getGetter(FieldModel model); static Method getVolatileGetter(FieldModel model); static Method getSetter(FieldModel model); static Method getOrderedSetter(FieldModel model); static void appendImported(SortedSet<Class> imported, StringBuilder sb); static void appendPackage(DataValueModel<?> dvmodel, StringBuilder sb); static String getPackage(DataValueModel<?> dvmodel); static int fieldSize(FieldModel model); static TreeSet<Class> newImported(); static boolean shouldImport(Class type); static Map.Entry<String, FieldModel>[] heapSizeOrderedFieldsGrouped(DataValueModel<?> dvmodel); static int computeOffset(int offset, FieldModel model); static int computeNonScalarOffset(DataValueModel dvmodel, Class type); T heapInstance(Class<T> tClass); Class acquireHeapClass(Class<T> tClass); T nativeInstance(Class<T> tClass); Class acquireNativeClass(Class<T> tClass); String generateNativeObject(Class<?> tClass); String generateNativeObject(DataValueModel<?> dvmodel); boolean isDumpCode(); void setDumpCode(boolean dumpCode); }### Answer: @Test public void testGenerateInterfaceWithEnumNativeInstance() { DataValueGenerator dvg = new DataValueGenerator(); JavaBeanInterfaceGetMyEnum jbie = dvg.nativeInstance(JavaBeanInterfaceGetMyEnum.class); Bytes bytes = ByteBufferBytes.wrap(ByteBuffer.allocate(64)); ((Byteable) jbie).bytes(bytes, 0L); jbie.setMyEnum(MyEnum.C); } @Test public void testGenerateInterfaceWithDateNativeInstace() { DataValueGenerator dvg = new DataValueGenerator(); JavaBeanInterfaceGetDate jbid = dvg.nativeInstance(JavaBeanInterfaceGetDate.class); Bytes bytes = ByteBufferBytes.wrap(ByteBuffer.allocate(64)); ((Byteable) jbid).bytes(bytes, 0L); jbid.setDate(new Date()); assertEquals(new Date(), jbid.getDate()); }
### Question: LightPauser implements Pauser { public LightPauser(long busyPeriodNS, long parkPeriodNS) { this.busyPeriodNS = busyPeriodNS; this.parkPeriodNS = parkPeriodNS; } LightPauser(long busyPeriodNS, long parkPeriodNS); @Override void reset(); @Override void pause(); void pause(long maxPauseNS); @Override void unpause(); static final long NO_BUSY_PERIOD; static final long NO_PAUSE_PERIOD; }### Answer: @Test public void testLightPauser() throws InterruptedException { final LightPauser pauser = new LightPauser(100 * 1000, 100 * 1000); Thread thread = new Thread() { @Override public void run() { while (!Thread.interrupted()) pauser.pause(); } }; thread.start(); for (int t = 0; t < 3; t++) { long start = System.nanoTime(); int runs = 10000000; for (int i = 0; i < runs; i++) pauser.unpause(); long time = System.nanoTime() - start; System.out.printf("Average time to unpark was %,d ns%n", time / runs); Thread.sleep(20); } thread.interrupt(); }
### Question: Maths { public static int intLog2(long num) { long l = Double.doubleToRawLongBits(num); return (int) ((l >> 52) - 1023); } static double round2(double d); static double round4(double d); static double round6(double d); static double round8(double d); static long power10(int n); static int nextPower2(int n, int min); static long nextPower2(long n, long min); static boolean isPowerOf2(int n); static boolean isPowerOf2(long n); static int hash(int n); static long hash(long n); static long hash(CharSequence cs); static int compare(long x, long y); static int intLog2(long num); static int toInt(long l, String error); static long agitate(long l); }### Answer: @Test public void testIntLog2() { for (int i = 0; i < 63; i++) { long l = 1L << i; assertEquals(i, Maths.intLog2(l)); } }
### Question: HelloWorldController { @RequestMapping("/") public String sayHello() { return "Hello,World!"; } @RequestMapping("/") String sayHello(); @PostMapping(value = "/request_param") String requestParam(@RequestParam(value = "name") String name); @PostMapping(value = "/request_body") UserInfo requestBody(@RequestParam(value = "name") String name, @RequestBody UserInfo info); @PostMapping(value = "/request_body1") UserInfo requestBody1(@RequestBody UserInfo info); }### Answer: @Test public void testSayHello() { assertEquals("Hello,World!",new HelloWorldController().sayHello()); }
### Question: OpenhabSseConnection extends SseConnection implements SseConnection.ISseDataListener { @Override protected String buildUrl() { return mUrl + "/rest/events?topics=" + buildTopic(); } OpenhabSseConnection(); void removeItemValueListener(IStateUpdateListener l); @Override void data(String data); }### Answer: @Test public void testBuildUrl() { OpenhabSseConnection c = new OpenhabSseConnection(); c.setServerUrl("URL"); c.setItemNames("cmdName"); assertEquals("URL/rest/events?topics=smarthome/items/cmdName/command", c.buildUrl()); c.setItemNames("cmdName","item1", "item2"); assertEquals("URL/rest/events?topics=smarthome/items/item1/statechanged,smarthome/items/item2/statechanged,smarthome/items/cmdName/command", c.buildUrl()); }
### Question: LocalizedFieldNames { public Lookup createLookup(List<String> keys) { return new LookupImpl(keys); } void setMessageSource(MessageSource messageSource); Lookup createLookup(List<String> keys); }### Answer: @Test public void backAndForth() { LocalizedFieldNames.Lookup lookup = localizedFieldNames.createLookup(Arrays.asList("dc.title")); final Locale english = new Locale("en"); String title = lookup.toLocalizedName("dc_title", english); Assert.assertEquals("Title", title); String fieldName = lookup.toFieldName(title, english); Assert.assertEquals("dc_title", fieldName); } @Test public void multiWord() { LocalizedFieldNames.Lookup lookup = localizedFieldNames.createLookup(Arrays.asList("dcterms.isReferencedBy")); final Locale english = new Locale("en"); String fieldName = lookup.toFieldName("isreferENCedby", english); Assert.assertEquals("dcterms_isReferencedBy", fieldName); }
### Question: BordersExtractor { public boolean isBorder(int edgeId) { int type = storage.getEdgeValue(edgeId, BordersGraphStorage.Property.TYPE); return (type == BordersGraphStorage.OPEN_BORDER || type == BordersGraphStorage.CONTROLLED_BORDER); } BordersExtractor(BordersGraphStorage storage, int[] avoidCountries); int getValue(int edgeId); boolean isBorder(int edgeId); boolean isControlledBorder(int edgeId); boolean isOpenBorder(int edgeId); boolean restrictedCountry(int edgeId); boolean isSameCountry(List<Integer> edgeIds); }### Answer: @Test public void TestDetectAnyBorder() { VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); BordersExtractor be = new BordersExtractor(_graphstorage, new int[0]); assertEquals(true, be.isBorder(1)); assertEquals(true, be.isBorder(2)); assertEquals(false, be.isBorder(3)); }
### Question: IsochronesResponse { public BoundingBox getBbox() { return bbox; } IsochronesResponse(IsochronesRequest request); IsochronesResponseInfo getResponseInformation(); BoundingBox getBbox(); }### Answer: @Test public void getBbox() { }
### Question: GeoJSONIsochronesResponse extends IsochronesResponse { @JsonProperty("features") public List<GeoJSONIsochroneBase> getIsochrones() { return isochroneResults; } GeoJSONIsochronesResponse(IsochronesRequest request, IsochroneMapCollection isoMaps); @JsonProperty("bbox") @JsonInclude(JsonInclude.Include.NON_NULL) @ApiModelProperty(value = "Bounding box that covers all returned isochrones", example = "[49.414057, 8.680894, 49.420514, 8.690123]") double[] getBBoxAsArray(); @JsonProperty("features") List<GeoJSONIsochroneBase> getIsochrones(); @JsonProperty("metadata") IsochronesResponseInfo getProperties(); @JsonProperty("type") final String type; }### Answer: @Test public void getIsochrones() { }
### Question: GeoJSONIsochronesResponse extends IsochronesResponse { @JsonProperty("metadata") public IsochronesResponseInfo getProperties() { return this.responseInformation; } GeoJSONIsochronesResponse(IsochronesRequest request, IsochroneMapCollection isoMaps); @JsonProperty("bbox") @JsonInclude(JsonInclude.Include.NON_NULL) @ApiModelProperty(value = "Bounding box that covers all returned isochrones", example = "[49.414057, 8.680894, 49.420514, 8.690123]") double[] getBBoxAsArray(); @JsonProperty("features") List<GeoJSONIsochroneBase> getIsochrones(); @JsonProperty("metadata") IsochronesResponseInfo getProperties(); @JsonProperty("type") final String type; }### Answer: @Test public void getProperties() { }
### Question: GeoJSONIsochroneProperties { public Double getValue() { return value; } GeoJSONIsochroneProperties(Isochrone isochrone, Coordinate center, int groupIndex); int getGroupIndex(); Double getValue(); Double[] getCenter(); Double getArea(); Double getReachfactor(); Double getTotalPop(); }### Answer: @Test public void getValue() { }
### Question: GeoJSONIsochroneProperties { public Double[] getCenter() { return center; } GeoJSONIsochroneProperties(Isochrone isochrone, Coordinate center, int groupIndex); int getGroupIndex(); Double getValue(); Double[] getCenter(); Double getArea(); Double getReachfactor(); Double getTotalPop(); }### Answer: @Test public void getCenter() { }
### Question: GeoJSONIsochroneProperties { public Double getArea() { return area; } GeoJSONIsochroneProperties(Isochrone isochrone, Coordinate center, int groupIndex); int getGroupIndex(); Double getValue(); Double[] getCenter(); Double getArea(); Double getReachfactor(); Double getTotalPop(); }### Answer: @Test public void getArea() { }
### Question: GeoJSONIsochroneProperties { public Double getReachfactor() { return reachfactor; } GeoJSONIsochroneProperties(Isochrone isochrone, Coordinate center, int groupIndex); int getGroupIndex(); Double getValue(); Double[] getCenter(); Double getArea(); Double getReachfactor(); Double getTotalPop(); }### Answer: @Test public void getReachfactor() { }
### Question: AvoidBordersEdgeFilter implements EdgeFilter { @Override public final boolean accept(EdgeIteratorState iter) { if (!isStorageBuilt) return true; if (avoidBorders != BordersExtractor.Avoid.NONE) { switch(avoidBorders) { case ALL: if(bordersExtractor.isBorder(iter.getEdge())) { return false; } break; case CONTROLLED: if(bordersExtractor.isControlledBorder(iter.getEdge())) { return false; } break; default: break; } } return !avoidCountries || !bordersExtractor.restrictedCountry(iter.getEdge()); } AvoidBordersEdgeFilter(RouteSearchParameters searchParams, BordersGraphStorage extBorders); AvoidBordersEdgeFilter(RouteSearchParameters searchParams, GraphStorage graphStorage); @Override final boolean accept(EdgeIteratorState iter); }### Answer: @Test public void TestAvoidSpecificBorders() { _searchParams.setAvoidBorders(BordersExtractor.Avoid.NONE); _searchParams.setAvoidCountries(new int[] {1, 5}); AvoidBordersEdgeFilter filter = new AvoidBordersEdgeFilter(_searchParams, _graphStorage); VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); assertFalse(filter.accept(ve1)); assertTrue(filter.accept(ve2)); assertFalse(filter.accept(ve3)); } @Test public void TestAvoidSpecificAndControlledBorders() { _searchParams.setAvoidBorders(BordersExtractor.Avoid.CONTROLLED); _searchParams.setAvoidCountries(new int[] {3}); AvoidBordersEdgeFilter filter = new AvoidBordersEdgeFilter(_searchParams, _graphStorage); VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); assertFalse(filter.accept(ve1)); assertFalse(filter.accept(ve2)); assertTrue(filter.accept(ve3)); } @Test public void TestAvoidAllBorders() { _searchParams.setAvoidBorders(BordersExtractor.Avoid.ALL); _searchParams.setAvoidCountries(new int[] {}); AvoidBordersEdgeFilter filter = new AvoidBordersEdgeFilter(_searchParams, _graphStorage); VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); assertFalse(filter.accept(ve1)); assertFalse(filter.accept(ve2)); assertTrue(filter.accept(ve3)); } @Test public void TestAvoidControlledBorders() { _searchParams.setAvoidBorders(BordersExtractor.Avoid.CONTROLLED); _searchParams.setAvoidCountries(new int[] {}); AvoidBordersEdgeFilter filter = new AvoidBordersEdgeFilter(_searchParams, _graphStorage); VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); assertFalse(filter.accept(ve1)); assertTrue(filter.accept(ve2)); assertTrue(filter.accept(ve3)); } @Test public void TestAvoidNoBorders() { _searchParams.setAvoidBorders(BordersExtractor.Avoid.NONE); _searchParams.setAvoidCountries(new int[] {}); AvoidBordersEdgeFilter filter = new AvoidBordersEdgeFilter(_searchParams, _graphStorage); VirtualEdgeIteratorState ve1 = generateEdge(1); VirtualEdgeIteratorState ve2 = generateEdge(2); VirtualEdgeIteratorState ve3 = generateEdge(3); assertTrue(filter.accept(ve1)); assertTrue(filter.accept(ve2)); assertTrue(filter.accept(ve3)); }
### Question: MatrixRequestHandler { public static int convertMetrics(MatrixRequestEnums.Metrics[] metrics) throws ParameterValueException { List<String> metricsAsStrings = new ArrayList<>(); for (int i=0; i<metrics.length; i++) { metricsAsStrings.add(metrics[i].toString()); } String concatMetrics = String.join("|", metricsAsStrings); int combined = MatrixMetricsType.getFromString(concatMetrics); if (combined == MatrixMetricsType.UNKNOWN) throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_METRICS); return combined; } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }### Answer: @Test public void convertMetricsTest() throws ParameterValueException { Assert.assertEquals(1, MatrixRequestHandler.convertMetrics(new MatrixRequestEnums.Metrics[] {MatrixRequestEnums.Metrics.DURATION})); Assert.assertEquals(2, MatrixRequestHandler.convertMetrics(new MatrixRequestEnums.Metrics[] {MatrixRequestEnums.Metrics.DISTANCE})); Assert.assertEquals(3, MatrixRequestHandler.convertMetrics(new MatrixRequestEnums.Metrics[] {MatrixRequestEnums.Metrics.DURATION, MatrixRequestEnums.Metrics.DISTANCE})); }
### Question: MatrixRequestHandler { protected static Coordinate[] convertLocations(List<List<Double>> locations, int numberOfRoutes) throws ParameterValueException, ServerLimitExceededException { if (locations == null || locations.size() < 2) throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_LOCATIONS); int maximumNumberOfRoutes = MatrixServiceSettings.getMaximumRoutes(false); if (numberOfRoutes > maximumNumberOfRoutes) throw new ServerLimitExceededException(MatrixErrorCodes.PARAMETER_VALUE_EXCEEDS_MAXIMUM, "Only a total of " + maximumNumberOfRoutes + " routes are allowed."); ArrayList<Coordinate> locationCoordinates = new ArrayList<>(); for (List<Double> coordinate : locations) { locationCoordinates.add(convertSingleLocationCoordinate(coordinate)); } try { return locationCoordinates.toArray(new Coordinate[locations.size()]); } catch (NumberFormatException | ArrayStoreException | NullPointerException ex) { throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_LOCATIONS); } } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }### Answer: @Test(expected = ParameterValueException.class) public void notEnoughLocationsTest() throws ParameterValueException, ServerLimitExceededException { MatrixRequestHandler.convertLocations(minimalLocations, 5); } @Test(expected = ServerLimitExceededException.class) public void maximumExceedingLocationsTest() throws ParameterValueException, ServerLimitExceededException { MatrixRequestHandler.convertLocations(listOfBareCoordinatesList, maximumRoutes); } @Test public void convertLocationsTest() throws ParameterValueException, ServerLimitExceededException { Coordinate[] coordinates = MatrixRequestHandler.convertLocations(listOfBareCoordinatesList, 3); Assert.assertEquals(8.681495, coordinates[0].x, 0); Assert.assertEquals(49.41461, coordinates[0].y, 0); Assert.assertEquals(Double.NaN, coordinates[0].z, 0); Assert.assertEquals(8.686507, coordinates[1].x, 0); Assert.assertEquals(49.41943, coordinates[1].y, 0); Assert.assertEquals(Double.NaN, coordinates[1].z, 0); Assert.assertEquals(8.687872, coordinates[2].x, 0); Assert.assertEquals(49.420318, coordinates[2].y, 0); Assert.assertEquals(Double.NaN, coordinates[2].z, 0); }
### Question: MatrixRequestHandler { protected static Coordinate convertSingleLocationCoordinate(List<Double> coordinate) throws ParameterValueException { if (coordinate.size() != 2) throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_LOCATIONS); return new Coordinate(coordinate.get(0), coordinate.get(1)); } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }### Answer: @Test public void convertSingleLocationCoordinateTest() throws ParameterValueException { List<Double> locationsList = new ArrayList<>(); locationsList.add(8.681495); locationsList.add(49.41461); Coordinate coordinates = MatrixRequestHandler.convertSingleLocationCoordinate(locationsList); Assert.assertEquals(8.681495, coordinates.x, 0); Assert.assertEquals(49.41461, coordinates.y, 0); Assert.assertEquals(Double.NaN, coordinates.z, 0); } @Test(expected = ParameterValueException.class) public void convertWrongSingleLocationCoordinateTest() throws ParameterValueException { List<Double> locationsList = new ArrayList<>(); locationsList.add(8.681495); locationsList.add(49.41461); locationsList.add(123.0); MatrixRequestHandler.convertSingleLocationCoordinate(locationsList); }
### Question: MatrixRequestHandler { protected static Coordinate[] convertSources(String[] sourcesIndex, Coordinate[] locations) throws ParameterValueException { int length = sourcesIndex.length; if (length == 0) return locations; if (length == 1 && "all".equalsIgnoreCase(sourcesIndex[0])) return locations; try { ArrayList<Coordinate> indexCoordinateArray = convertIndexToLocations(sourcesIndex, locations); return indexCoordinateArray.toArray(new Coordinate[0]); } catch (Exception ex) { throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_SOURCES); } } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }### Answer: @Test public void convertSourcesTest() throws ParameterValueException { String[] emptySources = new String[0]; Coordinate[] convertedSources = MatrixRequestHandler.convertSources(emptySources, this.coordinates); Assert.assertEquals(8.681495, convertedSources[0].x, 0); Assert.assertEquals(49.41461, convertedSources[0].y, 0); Assert.assertEquals(Double.NaN, convertedSources[0].z, 0); Assert.assertEquals(8.686507, convertedSources[1].x, 0); Assert.assertEquals(49.41943, convertedSources[1].y, 0); Assert.assertEquals(Double.NaN, convertedSources[1].z, 0); Assert.assertEquals(8.687872, convertedSources[2].x, 0); Assert.assertEquals(49.420318, convertedSources[2].y, 0); Assert.assertEquals(Double.NaN, convertedSources[2].z, 0); String[] allSources = new String[]{"all"}; convertedSources = MatrixRequestHandler.convertSources(allSources, this.coordinates); Assert.assertEquals(8.681495, convertedSources[0].x, 0); Assert.assertEquals(49.41461, convertedSources[0].y, 0); Assert.assertEquals(Double.NaN, convertedSources[0].z, 0); Assert.assertEquals(8.686507, convertedSources[1].x, 0); Assert.assertEquals(49.41943, convertedSources[1].y, 0); Assert.assertEquals(Double.NaN, convertedSources[1].z, 0); Assert.assertEquals(8.687872, convertedSources[2].x, 0); Assert.assertEquals(49.420318, convertedSources[2].y, 0); Assert.assertEquals(Double.NaN, convertedSources[2].z, 0); String[] secondSource = new String[]{"1"}; convertedSources = MatrixRequestHandler.convertSources(secondSource, this.coordinates); Assert.assertEquals(8.686507, convertedSources[0].x, 0); Assert.assertEquals(49.41943, convertedSources[0].y, 0); Assert.assertEquals(Double.NaN, convertedSources[0].z, 0); } @Test(expected = ParameterValueException.class) public void convertWrongSourcesTest() throws ParameterValueException { String[] wrongSource = new String[]{"foo"}; MatrixRequestHandler.convertSources(wrongSource, this.coordinates); }
### Question: MatrixRequestHandler { protected static Coordinate[] convertDestinations(String[] destinationsIndex, Coordinate[] locations) throws ParameterValueException { int length = destinationsIndex.length; if (length == 0) return locations; if (length == 1 && "all".equalsIgnoreCase(destinationsIndex[0])) return locations; try { ArrayList<Coordinate> indexCoordinateArray = convertIndexToLocations(destinationsIndex, locations); return indexCoordinateArray.toArray(new Coordinate[0]); } catch (Exception ex) { throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_DESTINATIONS); } } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }### Answer: @Test public void convertDestinationsTest() throws ParameterValueException { String[] emptyDestinations = new String[0]; Coordinate[] convertedDestinations = MatrixRequestHandler.convertDestinations(emptyDestinations, this.coordinates); Assert.assertEquals(8.681495, convertedDestinations[0].x, 0); Assert.assertEquals(49.41461, convertedDestinations[0].y, 0); Assert.assertEquals(Double.NaN, convertedDestinations[0].z, 0); Assert.assertEquals(8.686507, convertedDestinations[1].x, 0); Assert.assertEquals(49.41943, convertedDestinations[1].y, 0); Assert.assertEquals(Double.NaN, convertedDestinations[1].z, 0); Assert.assertEquals(8.687872, convertedDestinations[2].x, 0); Assert.assertEquals(49.420318, convertedDestinations[2].y, 0); Assert.assertEquals(Double.NaN, convertedDestinations[2].z, 0); String[] allDestinations = new String[]{"all"}; convertedDestinations = MatrixRequestHandler.convertDestinations(allDestinations, this.coordinates); Assert.assertEquals(8.681495, convertedDestinations[0].x, 0); Assert.assertEquals(49.41461, convertedDestinations[0].y, 0); Assert.assertEquals(Double.NaN, convertedDestinations[0].z, 0); Assert.assertEquals(8.686507, convertedDestinations[1].x, 0); Assert.assertEquals(49.41943, convertedDestinations[1].y, 0); Assert.assertEquals(Double.NaN, convertedDestinations[1].z, 0); Assert.assertEquals(8.687872, convertedDestinations[2].x, 0); Assert.assertEquals(49.420318, convertedDestinations[2].y, 0); Assert.assertEquals(Double.NaN, convertedDestinations[2].z, 0); String[] secondDestination = new String[]{"1"}; convertedDestinations = MatrixRequestHandler.convertDestinations(secondDestination, this.coordinates); Assert.assertEquals(8.686507, convertedDestinations[0].x, 0); Assert.assertEquals(49.41943, convertedDestinations[0].y, 0); Assert.assertEquals(Double.NaN, convertedDestinations[0].z, 0); } @Test(expected = ParameterValueException.class) public void convertWrongDestinationsTest() throws ParameterValueException { String[] wrongDestinations = new String[]{"foo"}; MatrixRequestHandler.convertDestinations(wrongDestinations, this.coordinates); }
### Question: MatrixRequestHandler { protected static ArrayList<Coordinate> convertIndexToLocations(String[] index, Coordinate[] locations) { ArrayList<Coordinate> indexCoordinates = new ArrayList<>(); for (String indexString : index) { int indexInteger = Integer.parseInt(indexString); indexCoordinates.add(locations[indexInteger]); } return indexCoordinates; } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }### Answer: @Test public void convertIndexToLocationsTest() throws Exception { ArrayList<Coordinate> coordinate = MatrixRequestHandler.convertIndexToLocations(new String[]{"1"}, this.coordinates); Assert.assertEquals(8.686507, coordinate.get(0).x, 0); Assert.assertEquals(49.41943, coordinate.get(0).y, 0); Assert.assertEquals(Double.NaN, coordinate.get(0).z, 0); } @Test(expected = Exception.class) public void convertWrongIndexToLocationsTest() throws Exception { MatrixRequestHandler.convertIndexToLocations(new String[]{"foo"}, this.coordinates); }
### Question: MatrixRequestHandler { protected static DistanceUnit convertUnits(APIEnums.Units unitsIn) throws ParameterValueException { DistanceUnit units = DistanceUnitUtil.getFromString(unitsIn.toString(), DistanceUnit.UNKNOWN); if (units == DistanceUnit.UNKNOWN) throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_UNITS, unitsIn.toString()); return units; } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }### Answer: @Test public void convertUnitsTest() throws ParameterValueException { Assert.assertEquals(DistanceUnit.METERS, MatrixRequestHandler.convertUnits(APIEnums.Units.METRES)); Assert.assertEquals(DistanceUnit.KILOMETERS, MatrixRequestHandler.convertUnits(APIEnums.Units.KILOMETRES)); Assert.assertEquals(DistanceUnit.MILES, MatrixRequestHandler.convertUnits(APIEnums.Units.MILES)); }
### Question: MatrixRequestHandler { protected static int convertToMatrixProfileType(APIEnums.Profile profile) throws ParameterValueException { try { int profileFromString = RoutingProfileType.getFromString(profile.toString()); if (profileFromString == 0) { throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_PROFILE); } return profileFromString; } catch (Exception e) { throw new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_VALUE, MatrixRequest.PARAM_PROFILE); } } private MatrixRequestHandler(); static MatrixResult generateMatrixFromRequest(MatrixRequest request); static org.heigit.ors.matrix.MatrixRequest convertMatrixRequest(MatrixRequest request); static int convertMetrics(MatrixRequestEnums.Metrics[] metrics); }### Answer: @Test public void convertToProfileTypeTest() throws ParameterValueException { Assert.assertEquals(1, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.DRIVING_CAR)); Assert.assertEquals(2, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.DRIVING_HGV)); Assert.assertEquals(10, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.CYCLING_REGULAR)); Assert.assertEquals(12, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.CYCLING_ROAD)); Assert.assertEquals(11, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.CYCLING_MOUNTAIN)); Assert.assertEquals(17, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.CYCLING_ELECTRIC)); Assert.assertEquals(20, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.FOOT_WALKING)); Assert.assertEquals(21, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.FOOT_HIKING)); Assert.assertEquals(30, MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.WHEELCHAIR)); } @Test(expected = ParameterValueException.class) public void convertToWrongMatrixProfileTypeTest() throws ParameterValueException { MatrixRequestHandler.convertToMatrixProfileType(APIEnums.Profile.forValue("foo")); }
### Question: MatrixRequest { public String getId() { return id; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }### Answer: @Test public void getIdTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); Assert.assertNull(matrixLocationsRequest.getId()); Assert.assertNull(matrixLocationsListRequest.getId()); }
### Question: MatrixRequest { public void setId(String id) { this.id = id; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }### Answer: @Test public void setIdTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); matrixLocationsRequest.setId("foo1"); matrixLocationsListRequest.setId("foo2"); Assert.assertEquals("foo1", matrixLocationsRequest.getId()); Assert.assertEquals("foo2", matrixLocationsListRequest.getId()); }
### Question: MatrixRequest { public boolean hasId() { return this.id != null; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }### Answer: @Test public void hasIdTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); Assert.assertFalse(matrixLocationsRequest.hasId()); Assert.assertFalse(matrixLocationsListRequest.hasId()); matrixLocationsRequest.setId("foo1"); matrixLocationsListRequest.setId("foo2"); Assert.assertTrue(matrixLocationsRequest.hasId()); Assert.assertTrue(matrixLocationsListRequest.hasId()); }
### Question: AvoidAreasEdgeFilter implements EdgeFilter { @Override public final boolean accept(EdgeIteratorState iter ) { if (env == null) return true; boolean inEnv = false; PointList pl = iter.fetchWayGeometry(3); int size = pl.getSize(); double eMinX = Double.MAX_VALUE; double eMinY = Double.MAX_VALUE; double eMaxX = Double.MIN_VALUE; double eMaxY = Double.MIN_VALUE; for (int j = 0; j < pl.getSize(); j++) { double x = pl.getLon(j); double y = pl.getLat(j); if (env.contains(x, y)) { inEnv = true; break; } if (x < eMinX) eMinX = x; if (y < eMinY) eMinY = y; if (x > eMaxX) eMaxX = x; if (y > eMaxY) eMaxY = y; } if (inEnv || !(eMinX > env.getMaxX() || eMaxX < env.getMinX() || eMinY > env.getMaxY() || eMaxY < env.getMinY())) { coordSequence = new DefaultCoordinateSequence(new Coordinate[1], 1); if (size >= 2) { coordSequence.resize(size); for (int j = 0; j < size; j++) { double x = pl.getLon(j); double y = pl.getLat(j); Coordinate c = coordSequence.getCoordinate(j); if (c == null) { c = new Coordinate(x, y); coordSequence.setCoordinate(j, c); } else { c.x = x; c.y = y; } } LineString ls = geomFactory.createLineString(coordSequence); for (int i = 0; i < polys.length; i++) { Polygon poly = polys[i]; if (poly.contains(ls) || ls.crosses(poly)) { return false; } } } else { return false; } } return true; } AvoidAreasEdgeFilter(Polygon[] polys); @Override final boolean accept(EdgeIteratorState iter ); }### Answer: @Test public void TestAvoidPolygons() { EdgeIteratorState iter1 = _graphStorage.edge(0, 1, 100, true); iter1.setWayGeometry(Helper.createPointList(0, 0, 10, 0)); EdgeIteratorState iter2 = _graphStorage.edge(0, 2, 200, true); iter2.setWayGeometry(Helper.createPointList(0, 0, -10, 0)); GeometryFactory gf = new GeometryFactory(); Polygon poly = gf.createPolygon(new Coordinate[]{ new Coordinate(-1,5), new Coordinate(1,5), new Coordinate(1,6), new Coordinate(-1,5)}); AvoidAreasEdgeFilter filter = new AvoidAreasEdgeFilter(new Polygon[] {poly}); assertFalse(filter.accept(iter1)); assertTrue(filter.accept(iter2)); }
### Question: MatrixRequest { public APIEnums.Profile getProfile() { return profile; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }### Answer: @Test public void getProfileTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); Assert.assertNull(matrixLocationsRequest.getProfile()); Assert.assertNull(matrixLocationsListRequest.getProfile()); }
### Question: MatrixRequest { public void setProfile(APIEnums.Profile profile) { this.profile = profile; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }### Answer: @Test public void setProfileTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); matrixLocationsRequest.setProfile(APIEnums.Profile.DRIVING_CAR); Assert.assertEquals(APIEnums.Profile.DRIVING_CAR, matrixLocationsRequest.getProfile()); matrixLocationsListRequest.setProfile(APIEnums.Profile.DRIVING_HGV); Assert.assertEquals(APIEnums.Profile.DRIVING_HGV, matrixLocationsListRequest.getProfile()); }
### Question: MatrixRequest { public List<List<Double>> getLocations() { return locations; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }### Answer: @Test public void getLocationsTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); Assert.assertEquals(listOfBareCoordinatesList, matrixLocationsRequest.getLocations()); Assert.assertEquals(listOfBareCoordinatesList, matrixLocationsListRequest.getLocations()); }
### Question: MatrixRequest { public void setLocations(List<List<Double>> locations) { this.locations = locations; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }### Answer: @Test public void setLocationsTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); matrixLocationsRequest.setLocations(listOfBareCoordinatesList); matrixLocationsListRequest.setLocations(listOfBareCoordinatesList); Assert.assertEquals(listOfBareCoordinatesList, matrixLocationsRequest.getLocations()); Assert.assertEquals(listOfBareCoordinatesList, matrixLocationsListRequest.getLocations()); }
### Question: MatrixRequest { public void setSources(String[] sources) { this.sources = sources; hasSources = true; } @JsonCreator MatrixRequest(@JsonProperty(value = "locations", required = true) List<List<Double>> locations); MatrixRequest(Double[][] locations); String getId(); void setId(String id); boolean hasId(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); List<List<Double>> getLocations(); void setLocations(List<List<Double>> locations); String[] getSources(); void setSources(String[] sources); boolean hasSources(); String[] getDestinations(); void setDestinations(String[] destinations); boolean hasDestinations(); MatrixRequestEnums.Metrics[] getMetrics(); Set<String> getMetricsStrings(); void setMetrics(MatrixRequestEnums.Metrics[] metrics); boolean hasMetrics(); boolean getResolveLocations(); void setResolveLocations(boolean resolveLocations); boolean hasResolveLocations(); APIEnums.Units getUnits(); void setUnits(APIEnums.Units units); boolean hasUnits(); Boolean getOptimized(); void setOptimized(boolean optimized); boolean hasOptimized(); APIEnums.MatrixResponseType getResponseType(); void setResponseType(APIEnums.MatrixResponseType responseType); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_SOURCES; static final String PARAM_DESTINATIONS; static final String PARAM_METRICS; static final String PARAM_RESOLVE_LOCATIONS; static final String PARAM_UNITS; static final String PARAM_OPTIMIZED; }### Answer: @Test public void setSourcesTest() throws ParameterValueException { matrixLocationsRequest = new MatrixRequest(bareCoordinates); matrixLocationsListRequest = new MatrixRequest(listOfBareCoordinatesList); matrixLocationsRequest.setSources(new String[]{"foo"}); matrixLocationsListRequest.setSources(new String[]{"foo"}); Assert.assertArrayEquals(new String[]{"foo"}, matrixLocationsRequest.getSources()); Assert.assertArrayEquals(new String[]{"foo"}, matrixLocationsListRequest.getSources()); }
### Question: RouteRequestRoundTripOptions { public void setLength(Float length) { this.length = length; hasLength = true; } Float getLength(); void setLength(Float length); Integer getPoints(); void setPoints(Integer points); Long getSeed(); void setSeed(Long seed); boolean hasLength(); boolean hasPoints(); boolean hasSeed(); static final String PARAM_LENGTH; static final String PARAM_POINTS; static final String PARAM_SEED; }### Answer: @Test public void testSetLength() { Assert.assertFalse(options.hasLength()); options.setLength(123.4f); Assert.assertTrue(options.hasLength()); Assert.assertEquals((Float)123.4f, options.getLength()); }
### Question: RouteRequestRoundTripOptions { public void setPoints(Integer points) { this.points = points; hasPoints = true; } Float getLength(); void setLength(Float length); Integer getPoints(); void setPoints(Integer points); Long getSeed(); void setSeed(Long seed); boolean hasLength(); boolean hasPoints(); boolean hasSeed(); static final String PARAM_LENGTH; static final String PARAM_POINTS; static final String PARAM_SEED; }### Answer: @Test public void testSetPoints() { Assert.assertFalse(options.hasPoints()); options.setPoints(12); Assert.assertTrue(options.hasPoints()); Assert.assertEquals((Integer) 12, options.getPoints()); }
### Question: RouteRequestRoundTripOptions { public void setSeed(Long seed) { this.seed = seed; hasSeed = true; } Float getLength(); void setLength(Float length); Integer getPoints(); void setPoints(Integer points); Long getSeed(); void setSeed(Long seed); boolean hasLength(); boolean hasPoints(); boolean hasSeed(); static final String PARAM_LENGTH; static final String PARAM_POINTS; static final String PARAM_SEED; }### Answer: @Test public void testSetSeed() { Assert.assertFalse(options.hasSeed()); options.setSeed(1234567890l); Assert.assertTrue(options.hasSeed()); Assert.assertEquals((Long) 1234567890l, options.getSeed()); }
### Question: ORSGraphHopper extends GraphHopper { public GHResponse constructFreeHandRoute(GHRequest request) { LineString directRouteGeometry = constructFreeHandRouteGeometry(request); PathWrapper directRoutePathWrapper = constructFreeHandRoutePathWrapper(directRouteGeometry); GHResponse directRouteResponse = new GHResponse(); directRouteResponse.add(directRoutePathWrapper); directRouteResponse.getHints().put("skipped_segment", "true"); return directRouteResponse; } ORSGraphHopper(GraphProcessContext procCntx); ORSGraphHopper(); @Override GraphHopper init(CmdArgs args); @SuppressWarnings("unchecked") @Override GraphHopper importOrLoad(); @Override List<Path> calcPaths(GHRequest request, GHResponse ghRsp); RouteSegmentInfo getRouteSegment(double[] latitudes, double[] longitudes, String vehicle); GHResponse constructFreeHandRoute(GHRequest request); HashMap<Integer, Long> getTmcGraphEdges(); HashMap<Long, ArrayList<Integer>> getOsmId2EdgeIds(); @Override void postProcessing(); GraphHopper setCoreEnabled(boolean enable); final boolean isCoreEnabled(); void initCoreAlgoFactoryDecorator(); final CoreAlgoFactoryDecorator getCoreFactoryDecorator(); GraphHopper setCoreLMEnabled(boolean enable); final boolean isCoreLMEnabled(); void initCoreLMAlgoFactoryDecorator(); final boolean isCHAvailable(String weighting); final boolean isLMAvailable(String weighting); final boolean isCoreAvailable(String weighting); final boolean isFastIsochroneAvailable(RouteSearchContext searchContext, TravelRangeType travelRangeType); final FastIsochroneFactory getFastIsochroneFactory(); Eccentricity getEccentricity(); }### Answer: @Test public void directRouteTest() { GHRequest ghRequest = new GHRequest(49.41281601436809, 8.686215877532959, 49.410163456220076, 8.687160015106201); GHResponse ghResponse = new ORSGraphHopper().constructFreeHandRoute(ghRequest); Assert.assertTrue(ghResponse.getHints().has("skipped_segment")); Assert.assertTrue(ghResponse.getHints().getBool("skipped_segment", false)); Assert.assertEquals(1, ghResponse.getAll().size()); PathWrapper directRouteWrapper = ghResponse.getAll().get(0); Assert.assertEquals(0, directRouteWrapper.getErrors().size()); Assert.assertEquals(0, directRouteWrapper.getDescription().size()); Assert.assertEquals(309.892f, directRouteWrapper.getDistance(), 3); Assert.assertEquals(0.0, directRouteWrapper.getAscend(), 0); Assert.assertEquals(0.0, directRouteWrapper.getDescend(), 0); Assert.assertEquals(0.0, directRouteWrapper.getRouteWeight(), 0); Assert.assertEquals(0, directRouteWrapper.getTime()); Assert.assertEquals("", directRouteWrapper.getDebugInfo()); Assert.assertEquals(2, directRouteWrapper.getInstructions().size()); Assert.assertEquals(1, directRouteWrapper.getInstructions().get(0).getPoints().size()); Assert.assertEquals(0, directRouteWrapper.getNumChanges()); Assert.assertEquals(0, directRouteWrapper.getLegs().size()); Assert.assertEquals(0, directRouteWrapper.getPathDetails().size()); Assert.assertNull(directRouteWrapper.getFare()); Assert.assertFalse(directRouteWrapper.isImpossible()); checkInstructions(directRouteWrapper.getInstructions()); checkPointList(directRouteWrapper.getWaypoints()); checkPointList(directRouteWrapper.getPoints()); }
### Question: BordersGraphStorageBuilder extends AbstractGraphStorageBuilder { @Override public void processWay(ReaderWay way) { LOGGER.warn("Borders requires geometry for the way!"); } BordersGraphStorageBuilder(); @Override GraphExtension init(GraphHopper graphhopper); void setBordersBuilder(CountryBordersReader cbr); @Override void processWay(ReaderWay way); @Override void processWay(ReaderWay way, Coordinate[] coords, HashMap<Integer, HashMap<String,String>> nodeTags); @Override void processEdge(ReaderWay way, EdgeIteratorState edge); @Override String getName(); String[] findBorderCrossing(Coordinate[] coords); CountryBordersReader getCbReader(); static final String BUILDER_NAME; }### Answer: @Test public void TestProcessWay() { ReaderWay rw = new ReaderWay(1); Coordinate[] cs = new Coordinate[] { new Coordinate(0.5,0.5), new Coordinate(1.5,0.5) }; _builder.processWay(rw, cs, null); Assert.assertEquals("c1", rw.getTag("country1")); Assert.assertEquals("c2", rw.getTag("country2")); ReaderWay rw2 = new ReaderWay(1); Coordinate[] cs2 = new Coordinate[] { new Coordinate(0.5,0.5), new Coordinate(0.75,0.5) }; _builder.processWay(rw2, cs2, null); Assert.assertEquals("c1", rw2.getTag("country1")); Assert.assertEquals("c1", rw2.getTag("country2")); }
### Question: BordersGraphStorageBuilder extends AbstractGraphStorageBuilder { public String[] findBorderCrossing(Coordinate[] coords) { ArrayList<CountryBordersPolygon> countries = new ArrayList<>(); boolean hasInternational = false; boolean overlap = false; int lsLen = coords.length; if(lsLen > 1) { for(int i=0; i<lsLen; i++) { Coordinate c = coords[i]; if(!Double.isNaN(c.x) && !Double.isNaN(c.y)) { CountryBordersPolygon[] cnts = cbReader.getCandidateCountry(c); for (CountryBordersPolygon cbp : cnts) { if (!countries.contains(cbp)) { countries.add(cbp); } } if(cnts.length == 0) hasInternational = true; } } } if(countries.size() > 1) { ArrayList<CountryBordersPolygon> temp = new ArrayList<>(); for(int i=0; i<lsLen; i++) { Coordinate c = coords[i]; if(!Double.isNaN(c.x) && !Double.isNaN(c.y)) { boolean found = false; int countriesFound = 0; for(CountryBordersPolygon cbp : countries) { if (cbp.inArea(c)) { found = true; countriesFound++; if(!temp.contains(cbp)) { temp.add(cbp); } } } if(countriesFound > 1) { overlap = true; } if(!found) { hasInternational = true; } } } countries = temp; } if(countries.size() > 1 && overlap) { boolean crosses = false; LineString ls = gf.createLineString(coords); for (CountryBordersPolygon cp : countries) { if (cp.crossesBoundary(ls)) { crosses = true; break; } } if(!crosses) { CountryBordersPolygon cp = countries.get(0); countries.clear(); countries.add(cp); } } ArrayList<String> names = new ArrayList<>(); for(int i=0; i<countries.size(); i++) { if (!names.contains(countries.get(i).getName())) names.add(countries.get(i).getName()); } if(hasInternational && !countries.isEmpty()) { names.add(CountryBordersReader.INTERNATIONAL_NAME); } return names.toArray(new String[names.size()]); } BordersGraphStorageBuilder(); @Override GraphExtension init(GraphHopper graphhopper); void setBordersBuilder(CountryBordersReader cbr); @Override void processWay(ReaderWay way); @Override void processWay(ReaderWay way, Coordinate[] coords, HashMap<Integer, HashMap<String,String>> nodeTags); @Override void processEdge(ReaderWay way, EdgeIteratorState edge); @Override String getName(); String[] findBorderCrossing(Coordinate[] coords); CountryBordersReader getCbReader(); static final String BUILDER_NAME; }### Answer: @Test public void TestFindBorderCrossing() { String[] names = _builder.findBorderCrossing(new Coordinate[] { new Coordinate(0.5,0.5), new Coordinate(1.5,0.5) }); Assert.assertEquals(2, names.length); Assert.assertTrue(names[0].equals("c1") || names[1].equals("c1")); Assert.assertTrue(names[0].equals("c2") || names[1].equals("c2")); } @Test public void TestOverlappingRegion() { String[] names = _builder.findBorderCrossing(new Coordinate[] { new Coordinate(101.5,101.5), new Coordinate(102.5,101.5) }); Assert.assertEquals(2, names.length); String[] names2 = _builder.findBorderCrossing(new Coordinate[] { new Coordinate(101.5,101.5), new Coordinate(101.75,101.5) }); Assert.assertEquals(1, names2.length); }
### Question: IsochronesRequest { public String getId() { return id; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }### Answer: @Test public void getIdTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertNull(request.getId()); }
### Question: IsochronesRequest { public void setId(String id) { this.id = id; this.hasId = true; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }### Answer: @Test public void setIdTest() { IsochronesRequest request = new IsochronesRequest(); request.setId("foo"); Assert.assertEquals("foo", request.getId()); }
### Question: IsochronesRequest { public boolean hasId() { return hasId; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }### Answer: @Test public void hasIdTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertFalse(request.hasId()); request.setId("foo"); Assert.assertTrue(request.hasId()); }
### Question: IsochronesRequest { public void setAreaUnit(APIEnums.Units areaUnit) { this.areaUnit = areaUnit; hasAreaUnits = true; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }### Answer: @Test public void setAreaUnitTest() throws ParameterValueException { IsochronesRequest request = new IsochronesRequest(); request.setAreaUnit(APIEnums.Units.forValue("km")); Assert.assertEquals(APIEnums.Units.KILOMETRES, request.getAreaUnit()); }
### Question: IsochronesRequest { public Double getSmoothing() { return smoothing; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }### Answer: @Test public void getSmoothingTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertNull(request.getSmoothing()); }
### Question: IsochronesRequest { public void setSmoothing(Double smoothing) { this.smoothing = smoothing; this.hasSmoothing = true; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }### Answer: @Test public void setSmoothingTest() { IsochronesRequest request = new IsochronesRequest(); request.setSmoothing(0.1); Assert.assertEquals(0.1, request.getSmoothing(), 0); }
### Question: IsochronesRequest { public boolean hasSmoothing() { return hasSmoothing; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }### Answer: @Test public void hasSmoothingTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertFalse(request.hasSmoothing()); request.setSmoothing(0.1); Assert.assertTrue(request.hasSmoothing()); }
### Question: IsochronesRequest { public APIEnums.RouteResponseType getResponseType() { return responseType; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }### Answer: @Test public void getResponseTypeTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertEquals(APIEnums.RouteResponseType.GEOJSON, request.getResponseType()); }
### Question: IsochronesRequest { public void setResponseType(APIEnums.RouteResponseType responseType) { this.responseType = responseType; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }### Answer: @Test public void setResponseTypeTest() { IsochronesRequest request = new IsochronesRequest(); request.setResponseType(APIEnums.RouteResponseType.JSON); Assert.assertEquals(APIEnums.RouteResponseType.JSON, request.getResponseType()); }
### Question: IsochronesRequest { public IsochronesRequestEnums.Attributes[] getAttributes() { return attributes; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }### Answer: @Test public void getAttributesTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertNull(request.getAttributes()); }
### Question: IsochronesRequest { public Double[][] getLocations() { return locations; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }### Answer: @Test public void getLocationTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertEquals(Double[][].class, request.getLocations().getClass()); }
### Question: IsochronesRequest { public void setLocationType(IsochronesRequestEnums.LocationType locationType) { this.locationType = locationType; hasLocationType = true; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }### Answer: @Test public void setLocationTypeTest() { IsochronesRequest request = new IsochronesRequest(); request.setLocationType(IsochronesRequestEnums.LocationType.DESTINATION); Assert.assertEquals(IsochronesRequestEnums.LocationType.DESTINATION, request.getLocationType()); }
### Question: WheelchairSidewalkWay extends PedestrianWay { @Override public boolean hasWayBeenFullyProcessed() { if(side == OSMAttachedSidewalkProcessor.Side.BOTH && lastPrepared == OSMAttachedSidewalkProcessor.Side.RIGHT) { return true; } return side == lastPrepared; } WheelchairSidewalkWay(ReaderWay way); @Override boolean hasWayBeenFullyProcessed(); @Override void prepare(); }### Answer: @Test public void TestInitiallyProcessedIfNoSidewalk() { WheelchairSidewalkWay way = new WheelchairSidewalkWay(new ReaderWay(1)); assertTrue(way.hasWayBeenFullyProcessed()); } @Test public void TestInitiallyNotProcessedIfSidewalk() { ReaderWay readerWay = new ReaderWay(1); readerWay.setTag("sidewalk", "left"); WheelchairSidewalkWay way = new WheelchairSidewalkWay(readerWay); assertFalse(way.hasWayBeenFullyProcessed()); }
### Question: IsochronesRequest { public APIEnums.Profile getProfile() { return profile; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }### Answer: @Test public void getProfileTest() { IsochronesRequest request = new IsochronesRequest(); Assert.assertNull(request.getProfile()); }
### Question: IsochronesRequest { public void setProfile(APIEnums.Profile profile) { this.profile = profile; } @JsonCreator IsochronesRequest(); String getId(); void setId(String id); boolean hasId(); APIEnums.Units getAreaUnit(); void setAreaUnit(APIEnums.Units areaUnit); boolean hasAreaUnits(); Double getSmoothing(); void setSmoothing(Double smoothing); boolean hasSmoothing(); APIEnums.RouteResponseType getResponseType(); void setResponseType(APIEnums.RouteResponseType responseType); boolean getIntersections(); void setIntersections(Boolean intersections); boolean hasIntersections(); APIEnums.Units getRangeUnit(); void setRangeUnit(APIEnums.Units rangeUnit); boolean hasRangeUnits(); IsochronesRequestEnums.Attributes[] getAttributes(); void setAttributes(IsochronesRequestEnums.Attributes[] attributes); boolean hasAttributes(); Double[][] getLocations(); void setLocations(Double[][] locations); boolean hasLocations(); IsochronesRequestEnums.LocationType getLocationType(); void setLocationType(IsochronesRequestEnums.LocationType locationType); boolean hasLocationType(); APIEnums.Profile getProfile(); void setProfile(APIEnums.Profile profile); RouteRequestOptions getIsochronesOptions(); void setIsochronesOptions(RouteRequestOptions isochronesOptions); boolean hasOptions(); List<Double> getRange(); void setRange(List<Double> range); boolean hasRange(); IsochronesRequestEnums.RangeType getRangeType(); void setRangeType(IsochronesRequestEnums.RangeType rangeType); boolean hasRangeType(); Double getInterval(); void setInterval(Double interval); boolean hasInterval(); static final String PARAM_ID; static final String PARAM_PROFILE; static final String PARAM_LOCATIONS; static final String PARAM_LOCATION_TYPE; static final String PARAM_OPTIONS; static final String PARAM_RANGE; static final String PARAM_RANGE_TYPE; static final String PARAM_RANGE_UNITS; static final String PARAM_AREA_UNITS; static final String PARAM_INTERSECTIONS; static final String PARAM_ATTRIBUTES; static final String PARAM_INTERVAL; static final String PARAM_SMOOTHING; }### Answer: @Test public void setProfileTest() { IsochronesRequest request = new IsochronesRequest(); request.setProfile(APIEnums.Profile.DRIVING_CAR); Assert.assertEquals(APIEnums.Profile.DRIVING_CAR, request.getProfile()); }