src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
PathSet implements Set<Path> { public boolean containsAncestor(Path path) { for (Path p : this) { if (p.isAncestorOf(path)) { return true; } } return false; } PathSet(); PathSet(Set<Path> delegate); boolean equals(Object o); int hashCode(); int size(); boolean isEmpty(); boolean contains(Object o); Object[] toArray();...
@Test public void containsAncestor() { assertTrue(data.remove(new Path("/"))); assertTrue(data.containsAncestor(new Path("/foo/baz"))); assertTrue(data.containsAncestor(new Path("/bar/baz"))); assertTrue(!data.containsAncestor(new Path("/foo"))); assertTrue(!data.containsAncestor(new Path("/baz"))); }
Path implements Iterable<String>, Serializable { public boolean isDescendantOf(Path other) { if (other.isRoot()) { if (isRoot()) { return false; } else if (isAbsolute()) { return true; } else { return false; } } else { return path.startsWith(other.path + SEPARATOR) && path.length() > other.path.length(); } } Path(Strin...
@Test public void isDescendantOf() { assertDescendant(new Path("/"), new Path("/foo")); assertDescendant(new Path("/"), new Path("/foo/bar")); assertDescendant(new Path("/foo"), new Path("/foo/bar")); assertNotDescendant(new Path("/foo"), new Path("/bar/foo")); assertNotDescendant(new Path("/foo"), new Path("/")); asse...
Path implements Iterable<String>, Serializable { public boolean isRoot() { return path.equals(SEPARATOR); } Path(String path); Path(String path, boolean canonize); Path canonical(); boolean isCanonical(); boolean isRoot(); boolean isAbsolute(); @Override boolean equals(Object obj); @Override int hashCode(); @Override ...
@Test public void isRoot() { assertTrue(new Path("/").isRoot()); assertTrue(!new Path("foo").isRoot()); assertTrue(!new Path("/foo").isRoot()); }
Path implements Iterable<String>, Serializable { public Iterator<String> iterator() { return new Iterator<String>() { int idx = 0; public boolean hasNext() { return idx < size(); } public String next() { return part(idx++); } public void remove() { throw new UnsupportedOperationException("Path parts iterator is read on...
@Test @SuppressWarnings("unused") public void iterator() { Path path = new Path("/foo/bar/baz"); Set<String> parts = new HashSet<String>(Arrays.asList(new String[]{"foo", "bar", "baz"})); for (String part : path) { assertTrue(parts.remove(part)); } assertTrue(parts.isEmpty()); for (String part : new Path("/")) { fail()...
Path implements Iterable<String>, Serializable { public Path parent() { if (isRoot()) { return null; } else { return new Path(path + "/.."); } } Path(String path); Path(String path, boolean canonize); Path canonical(); boolean isCanonical(); boolean isRoot(); boolean isAbsolute(); @Override boolean equals(Object obj);...
@Test public void parent() { assertTrue(new Path("/").parent() == null); assertEquals(new Path("/foo").parent(), new Path("/")); assertEquals(new Path("/foo/bar").parent(), new Path("/foo")); assertEquals(new Path("foo").parent(), new Path(".")); assertEquals(new Path("foo/bar").parent(), new Path("foo")); assertEquals...
Path implements Iterable<String>, Serializable { public String part(int index) { if (index < 0) { throw new IndexOutOfBoundsException(); } int start = isAbsolute() ? 1 : 0; for (int i = 0; i < index; i++) { start = path.indexOf(SEPARATOR, start); if (start < 0) { throw new IndexOutOfBoundsException(); } start++; } int ...
@Test public void part() { Path path = new Path("/foo/bar/baz"); assertEquals("foo", path.part(0)); assertEquals("bar", path.part(1)); assertEquals("baz", path.part(2)); path = new Path("foo/bar/baz"); assertEquals("foo", path.part(0)); assertEquals("bar", path.part(1)); assertEquals("baz", path.part(2)); }
Path implements Iterable<String>, Serializable { public int size() { if (isRoot()) { return 0; } int size = 0; int pos = 0; while (pos >= 0) { size++; pos = path.indexOf(SEPARATOR, pos + 1); } return size; } Path(String path); Path(String path, boolean canonize); Path canonical(); boolean isCanonical(); boolean isRoot...
@Test public void size() { assertEquals(new Path("/").size(), 0); assertEquals(new Path("/foo").size(), 1); assertEquals(new Path("/foo/bar").size(), 2); assertEquals(new Path("/foo/bar/baz").size(), 3); }
Path implements Iterable<String>, Serializable { public Path subpath(int idx) { if (idx <= 0) { throw new IndexOutOfBoundsException(); } final int size = size(); final boolean abs = isAbsolute(); int chunks = (abs) ? size + 1 : size; if (idx > chunks) { throw new IndexOutOfBoundsException(); } if (idx == chunks) { retu...
@Test public void subpath() { Path path = new Path("/foo/bar/baz"); assertEquals(new Path("/foo/bar/baz"), path.subpath(4)); assertEquals(new Path("/foo/bar"), path.subpath(3)); assertEquals(new Path("/foo"), path.subpath(2)); assertEquals(new Path("/"), path.subpath(1)); try { path.subpath(5); fail("expect index out o...
Path implements Iterable<String>, Serializable { public Path toRelative(Path ancestor) { if (isRoot()) { throw new IllegalStateException("Cannot make root path relative"); } if (!isDescendantOf(ancestor)) { throw new IllegalArgumentException("Cannot create relative path because this path: " + this + " is not descendant...
@Test public void toRelative() { try { new Path("/").toRelative(new Path("/")); fail(); } catch (IllegalStateException e) { } try { new Path("/foo/bar").toRelative(new Path("/bar")); fail(); } catch (IllegalArgumentException e) { } assertEquals(new Path("foo"), new Path("/foo").toRelative(new Path("/"))); assertEquals(...
PathSet implements Set<Path> { public boolean containsParent(Path path) { for (Path p : this) { if (p.isParentOf(path)) { return true; } } return false; } PathSet(); PathSet(Set<Path> delegate); boolean equals(Object o); int hashCode(); int size(); boolean isEmpty(); boolean contains(Object o); Object[] toArray(); T[]...
@Test public void containsParent() { assertTrue(!data.containsParent(new Path("/"))); assertTrue(data.containsParent(new Path("/foo"))); assertTrue(data.containsParent(new Path("/foo/baz"))); assertTrue(data.containsParent(new Path("/foo/bar/baz"))); assertTrue(data.containsParent(new Path("/foo/bar/baz/boz"))); assert...
PathSet implements Set<Path> { public void removeDescendants(Path path) { Iterator<Path> i = iterator(); while (i.hasNext()) { Path p = i.next(); if (p.isDescendantOf(path)) { i.remove(); } } } PathSet(); PathSet(Set<Path> delegate); boolean equals(Object o); int hashCode(); int size(); boolean isEmpty(); boolean cont...
@Test public void removeDescendants() { data.removeDescendants(new Path("/foo")); assertTrue(data.size() == 3); assertTrue(data.contains(new Path("/"))); assertTrue(data.contains(new Path("/bar"))); assertTrue(data.contains(new Path("/foo"))); data.removeDescendants(new Path("/")); assertTrue(data.size() == 1); assertT...
PathSet implements Set<Path> { public boolean removeWithDescendants(Path path) { boolean ret = remove(path); removeDescendants(path); return ret; } PathSet(); PathSet(Set<Path> delegate); boolean equals(Object o); int hashCode(); int size(); boolean isEmpty(); boolean contains(Object o); Object[] toArray(); T[] toArra...
@Test public void removeWithDescendants() { data.removeWithDescendants(new Path("/foo")); assertTrue(data.size() == 2); assertTrue(data.contains(new Path("/"))); assertTrue(data.contains(new Path("/bar"))); data.removeWithDescendants(new Path("/")); assertTrue(data.isEmpty()); }
Path implements Iterable<String>, Serializable { public Path append(Path relative) { if (relative == null) { throw new IllegalArgumentException("Argument 'relative' cannot be null"); } if (relative.isAbsolute()) { throw new IllegalArgumentException("Cannot append an absolute path"); } StringBuilder appended = new Strin...
@Test public void append() { assertEquals(new Path("/").append(new Path("foo")), new Path("/foo")); assertEquals(new Path("/").append(new Path("foo/bar")), new Path("/foo/bar")); assertEquals(new Path("/foo").append(new Path("bar")), new Path("/foo/bar")); assertEquals(new Path("/foo").append(new Path("../bar")), new P...
Path implements Iterable<String>, Serializable { @Override public String toString() { return path; } Path(String path); Path(String path, boolean canonize); Path canonical(); boolean isCanonical(); boolean isRoot(); boolean isAbsolute(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String ...
@Test public void construction() { assertEquals(new Path("/").toString(), "/"); assertEquals(new Path("/foo").toString(), "/foo"); assertEquals(new Path("/foo/").toString(), "/foo"); assertEquals(new Path("/foo/bar").toString(), "/foo/bar"); assertEquals(new Path("/foo/bar/").toString(), "/foo/bar"); assertEquals(new P...
Path implements Iterable<String>, Serializable { public String getName() { if (path.equals(SEPARATOR)) { return path; } else { int last = path.lastIndexOf(SEPARATOR); return path.substring(last + 1); } } Path(String path); Path(String path, boolean canonize); Path canonical(); boolean isCanonical(); boolean isRoot(); ...
@Test public void getName() { assertEquals(new Path("/").getName(), "/"); assertEquals(new Path("/foo").getName(), "foo"); assertEquals(new Path("/foo/bar").getName(), "bar"); assertEquals(new Path("foo").getName(), "foo"); assertEquals(new Path("foo/bar").getName(), "bar"); }
Path implements Iterable<String>, Serializable { public boolean isAbsolute() { return path.startsWith("/"); } Path(String path); Path(String path, boolean canonize); Path canonical(); boolean isCanonical(); boolean isRoot(); boolean isAbsolute(); @Override boolean equals(Object obj); @Override int hashCode(); @Overrid...
@Test public void isAbsolute() { assertTrue(new Path("/").isAbsolute()); assertTrue(new Path("/foo").isAbsolute()); assertTrue(new Path("/foo/bar").isAbsolute()); assertTrue(!new Path("foo").isAbsolute()); assertTrue(!new Path("foo/bar").isAbsolute()); }
Path implements Iterable<String>, Serializable { public boolean isCanonical() { int offset = 0; boolean text = false; if (path.equals(".")) { return true; } if (!isRoot() && path.endsWith("/")) { return false; } while (offset < path.length()) { String sub = path.substring(offset); if (sub.equals("/") || sub.equals(""))...
@Test public void isCannonical() { assertTrue(new Path("/", false).isCanonical()); assertTrue(new Path("a", false).isCanonical()); assertTrue(new Path("a/b", false).isCanonical()); assertTrue(new Path("a/b/c", false).isCanonical()); assertTrue(new Path("a/..b/c", false).isCanonical()); assertTrue(new Path("a/b/c..", fa...
Path implements Iterable<String>, Serializable { public boolean isChildOf(Path other) { return isDescendantOf(other) && size() == other.size() + 1; } Path(String path); Path(String path, boolean canonize); Path canonical(); boolean isCanonical(); boolean isRoot(); boolean isAbsolute(); @Override boolean equals(Object ...
@Test public void isChildOf() { assertChild(new Path("/"), new Path("/foo")); assertNotChild(new Path("/"), new Path("/foo/bar")); assertChild(new Path("/foo/bar"), new Path("/foo/bar/baz")); assertNotChild(new Path("/foo/bar"), new Path("/foo/baz/bar")); assertNotChild(new Path("/"), new Path("/")); assertNotChild(new...
PoiList { public List<OsmObject> createAlternateList() { return poiList.subList(1, poiList.size()); } private PoiList(); static synchronized PoiList getInstance(); List<OsmObject> getPoiList(); void setPoiList(List<OsmObject> poiList); List<OsmObject> createAlternateList(); void clearPoiList(); void sortList(final dou...
@Test public void createAlternateList() { List<OsmObject> alternateList = PoiList.getInstance().createAlternateList(); assertEquals(0, alternateList.size()); }
QuestionsPresenter implements QuestionsActivityContract.Presenter { @Override public void assessIntentData(URI uri) { if (uri != null) { try { Map<String, List<String>> list = Utilities.splitQuery(uri); String verifier = list.get(PreferenceList.OAUTH_VERIFIER).get(0); String token = list.get(PreferenceList.OAUTH_TOKEN)...
@Test public void assessIntentData() { URI uri = null; try { uri = new URI("http: } catch (URISyntaxException e) { e.printStackTrace(); } questionsPresenter.assessIntentData(uri); verify(preferences).setStringPreference("oauth_verifier", "1"); verify(preferences).setStringPreference("oauth_token", "1"); verify(view).st...
IntroPresenter implements IntroFragmentContract.Presenter { @Override public void getDetails() { String address = getAddress(); view.showDetails(poi.getName(), address, poi.getDrawable()); } IntroPresenter(IntroFragmentContract.View view); @Override void getDetails(); }
@Test public void addPoiToTextview() { introPresenter.getDetails(); verify(view).showDetails("Kitchen", " ", R.drawable.ic_restaurant); }
OsmLoginPresenter implements OsmLoginFragmentContract.Presenter { @Override public void clickedOsmLoginButton() { preferences.setStringPreference(PreferenceList.OAUTH_VERIFIER, ""); preferences.setStringPreference(PreferenceList.OAUTH_TOKEN, ""); preferences.setStringPreference(PreferenceList.OAUTH_TOKEN_SECRET, ""); v...
@Test public void checkPreferencesAreCleared() { presenter.clickedOsmLoginButton(); verify(view).startOAuth(); }
QuestionPresenter implements QuestionFragmentContract.Presenter { @Override public void getQuestion() { List<QuestionsContract> questions = this.listOfQuestions.getQuestion(); QuestionsContract questionsContract = questions.get(position); int question = questionsContract.getQuestion(); int color = questionsContract.get...
@Test public void getQuestionTest() { questionPresenter.getQuestion(); verify(view).showQuestion(anyInt(), anyString(), anyInt(), anyInt()); } @Test public void getPreviousAnswerTest() { questionPresenter.getQuestion(); verify(view).setPreviousAnswer(anyString()); }
QuestionPresenter implements QuestionFragmentContract.Presenter { @Override public void onAnswerSelected(int id) { List<QuestionsContract> questions = this.listOfQuestions.getQuestion(); QuestionsContract questionsContract = questions.get(position); int selectedColor = questionsContract.getColor(); int unselectedColor ...
@Test public void yesAnswerSelected() { questionPresenter.onAnswerSelected(R.id.answer_yes); verify(view).setBackgroundColor(anyInt(), anyInt(), anyInt()); } @Test public void noAnswerSelected() { questionPresenter.onAnswerSelected(R.id.answer_no); verify(view).setBackgroundColor(anyInt(), anyInt(), anyInt()); } @Test ...
MainActivityPresenter implements MainActivityContract.Presenter { @Override public void checkIfOauth(URI uri) { if (uri != null) { try { Map<String, List<String>> list = Utilities.splitQuery(uri); String verifier = list.get(PreferenceList.OAUTH_VERIFIER).get(0); String token = list.get(PreferenceList.OAUTH_TOKEN).get(0...
@Test public void checkIfInOAuthFlow() { URI url = null; try { url = new URI("http: } catch (URISyntaxException e) { e.printStackTrace(); } presenter.checkIfOauth(url); verify(view).startOAuth(); }
MainActivityPresenter implements MainActivityContract.Presenter { @Override public void showIfLoggedIn() { boolean loggedIn = preferences.getBooleanPreference(PreferenceList.LOGGED_IN_TO_OSM); int message; int button; String userName = getUserName(); if (loggedIn) { if ("".equals(userName)) { message = R.string.logged_...
@Test public void checkIfUsernameIsSetCorrectly() { presenter.showIfLoggedIn(); verify(view).showIfLoggedIn(anyInt(), anyInt(), (String) any()); }
QueryOverpass implements SourceContract.Overpass { @Override public String getOverpassUri(double latitude, double longitude, float accuracy) { float measuredAccuracy; if (accuracy < 20) { measuredAccuracy = 20; } else if (accuracy > 100) { measuredAccuracy = 100; } else { measuredAccuracy = accuracy; } String overpassL...
@Test public void testGenerateOverpassUri() { double latitude = 53; double longitude = -7; float accuracy = 50; String expected_uri = "https: String uri = queryOverpass.getOverpassUri(latitude, longitude, accuracy); assertEquals(expected_uri, uri); }
AboutPresenter implements MainActivityContract.AboutPresenter { @Override public void findVersion() { String version = BuildConfig.VERSION_NAME; view.setVersion(version); } AboutPresenter(MainActivityContract.AboutView view); @Override void findVersion(); @Override void getLicence(); @Override void getGitHub(); }
@Test public void checkVersionNameIsSet() { aboutPresenter.findVersion(); verify(view).setVersion(BuildConfig.VERSION_NAME); }
AboutPresenter implements MainActivityContract.AboutPresenter { @Override public void getLicence() { String uri = "http: view.visitUri(uri); } AboutPresenter(MainActivityContract.AboutView view); @Override void findVersion(); @Override void getLicence(); @Override void getGitHub(); }
@Test public void checkLicenceDetailsAreSet() { aboutPresenter.getLicence(); verify(view).visitUri("http: }
AboutPresenter implements MainActivityContract.AboutPresenter { @Override public void getGitHub() { String uri = "https: view.visitUri(uri); } AboutPresenter(MainActivityContract.AboutView view); @Override void findVersion(); @Override void getLicence(); @Override void getGitHub(); }
@Test public void checkSourceDetailsAreSet() { aboutPresenter.getGitHub(); verify(view).visitUri("https: }
Utilities { public static Map<String, List<String>> splitQuery(URI url) throws UnsupportedEncodingException { final Map<String, List<String>> query_pairs = new LinkedHashMap<>(); final String[] pairs = url.getQuery().split("&"); for (String pair : pairs) { final int idx = pair.indexOf("="); final String key = idx > 0 ?...
@Test public void splitqueryValidUrl() throws URISyntaxException, UnsupportedEncodingException { String uri = "http: URI url = new URI(uri); Map<String, List<String>> map = Utilities.splitQuery(url); assertEquals("[out:json]", map.get("data").get(0)); }
Utilities { public static float computeDistance(double latitude1, double longitude1, double latitude2, double longitude2) { int MAXITERS = 20; double lat1 = latitude1 * (Math.PI / 180.0); double lat2 = latitude2 * (Math.PI / 180.0); double lon1 = longitude1 * (Math.PI / 180.0); double lon2 = longitude2 * (Math.PI / 180...
@Test public void calculateDistance() { double lat1 = 53.1; double lon1 = -7.5; double lat2 = 53.2; double lon2 = -7.4; float distance = Utilities.computeDistance(lat1, lon1, lat2, lon2); assertEquals(12985, distance, 1); }
QueryOverpass implements SourceContract.Overpass { public String getType(JSONObject tags) throws JSONException { String type = ""; if (tags.has("amenity")) { type = tags.getString("amenity"); } if (tags.has("shop")) { type = tags.getString("shop"); } if (tags.has("tourism")) { type = tags.getString("tourism"); } if (ta...
@Test public void testGetOverpassResultPoiType() throws JSONException { String expected_result = "hairdresser"; JSONObject json = new JSONObject().put("amenity", expected_result); String result = queryOverpass.getType(json); assertEquals(expected_result, result); }
Answers { public static Map<String, String> getAnswerMap() { getInstance(); return answerMap; } private Answers(); static Map<String, String> getAnswerMap(); static void addAnswer(String question, String answer); static void clearAnswerList(); static void setPoiDetails(OsmObject osmObject); static long getPoiId(); sta...
@Test public void getKeyFromTag() { String tag = this.questionObject.getTag(); String expectedValue = this.questionObject.getAnswerYes(); String actualValue = Answers.getAnswerMap().get(tag); assertEquals(expectedValue, actualValue); }
Answers { public static Map<String, String> getChangesetTags() { getInstance(); return changesetTags; } private Answers(); static Map<String, String> getAnswerMap(); static void addAnswer(String question, String answer); static void clearAnswerList(); static void setPoiDetails(OsmObject osmObject); static long getPoiI...
@Test public void checkChangesetTagsAreSet() { Map<String, String> actualTags = Answers.getChangesetTags(); Map<String, String> expectedTags = new HashMap<>(); expectedTags.put("", ""); assertEquals(expectedTags, actualTags); }
NotHerePresenter implements NotHereFragmentContract.Presenter { @Override public void getPoiDetails() { String name = poiList.get(0).getName(); view.setTextview(name); view.setAdapter(alternateList); } NotHerePresenter(NotHereFragmentContract.View view); @Override void getPoiDetails(); @Override void onItemClicked(int ...
@Test public void addPoiToTextview() { notHerePresenter.getPoiDetails(); verify(view).setTextview("Kitchen"); }
NotHerePresenter implements NotHereFragmentContract.Presenter { @Override public void onItemClicked(int i) { ArrayList<OsmObject> intentList = new ArrayList<>(); intentList.add(0, this.alternateList.get(i)); PoiList.getInstance().setPoiList(intentList); view.startActivity(); } NotHerePresenter(NotHereFragmentContract.V...
@Test public void onClick() { notHerePresenter.onItemClicked(0); verify(view).startActivity(); }
QuestionsPresenter implements QuestionsActivityContract.Presenter { @Override public void addPoiNameToTextview() { List<OsmObject> poiList = PoiList.getInstance().getPoiList(); if (poiList.size() != 0) { String poiType = poiList.get(0).getType(); PoiContract listOfQuestions = PoiTypes.getPoiType(poiType); listOfQuestio...
@Test public void addPoiNameToTextViewTestSinglePoiInList() { List<OsmObject> poiList = new ArrayList<>(); poiList.add(new OsmObject(1, "node", "", "restaurant", 1, 1, 1)); PoiList.getInstance().setPoiList(poiList); when(preferences.getBooleanPreference(anyString())).thenReturn(true); questionsPresenter.addPoiNameToTex...
MigrationRouter { public List<MigrationPair> getMigrationPairOfPNode(int pNodeNo) { return allNodeMigrationPairs.get(pNodeNo); } MigrationRouter(int vNodes, int oldPNodeCount, int newPNodeCount); int getNewPNodeCount(); int getOldPNodeCount(); List<MigrationPair> getMigrationPairOfPNode(int pNodeNo); List<List<Migratio...
@Test public void testGetMigrationPairOfPNode() { MigrationRouter migrationRouter = new MigrationRouter(10000, 3, 4); System.out.println(migrationRouter.getMigrationPairOfPNode(0)); List<List<MigrationPair>> allNodeMigrationPairs = migrationRouter.getAllNodeMigrationPairs(); Assert.assertTrue( allNodeMigrationPairs.siz...
ConsistentReportServiceImpl implements ConsistentReportService { public List<ConsistentReportDO> queryConsistentReport(Map params) { return consistentReportDao.queryConsistentReport(params); } void setConsistentReportDao(ConsistentReportDao consistentReportDao); Integer saveConsistentReport(ConsistentReportDO consiste...
@Test public void testQueryConsistentReport() { }
PNode2VNodeMapping { public List<Integer> getVNodes(int pNode) { return vpmMapping.get( pNode ); } PNode2VNodeMapping(int vNodes, int pNodeCount); List<Integer> getVNodes(int pNode); int getPNodeCount(); List<List<Integer>> getVpmMapping(); }
@Test public void testGetVNodes() { PNode2VNodeMapping mapping = new PNode2VNodeMapping(12, 3); System.out.println( "vNodes: of (12,3): " + mapping); List<Integer> vNodes = mapping.getVNodes(1); System.out.println( "vNodes: of (12,3:1): " + vNodes ); Assert.assertEquals(6, vNodes.get(0).intValue()); Assert.assertEquals...
PropertiesLoadUtil { public static Properties loadProperties(String propLocation) { Properties properties = null; properties = loadAsFile(propLocation); if( properties != null) return properties; properties = loadAsResource(propLocation); return properties; } static Properties loadProperties(String propLocation); }
@Test public void testProperty() { Properties properties = PropertiesLoadUtil.loadProperties("./test/test/test/testp.properties"); assertEquals("value1", properties.get("key1")); }
JavaObjectSerializer implements Serializer { public byte[] serialize(Object o, Object arg) { byte[] bvalue = null; if( o == null ) { bvalue = new byte[]{ Byte.valueOf( (byte) 0 )}; return bvalue; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ObjectOutputStream oos = new ObjectOutputStream(baos); oos...
@Test public void testSerializeNull() { Serializer serializer = new JavaObjectSerializer(); byte[] bvalue = serializer.serialize(null, null); char c = (char) Byte.valueOf( (byte)0 ).byteValue(); byte s = "0".getBytes()[0] ; System.out.println("asc 0: " + s +", c: " + c); } @Test public void testSerialize() { Serializer...
JavaObjectSerializer implements Serializer { public Object deserialize(byte[] bvalue, Object deserializeTarget) { if( bvalue == null) return null; ByteArrayInputStream bais = new ByteArrayInputStream( bvalue ); try { ObjectInputStream ois = new ObjectInputStream(bais); Object obj = ois.readObject(); return obj; } catch...
@Test public void testDeserialize() { Serializer serializer = new JavaObjectSerializer(); String stringObj = "key001"; byte[] bvalue = serializer.serialize(stringObj, null); String result = (String) serializer.deserialize(bvalue, null); Assert.assertEquals("string serialize result",stringObj, result); }
StorageManager { protected void loadStorage(StorageConfig config) { driver.init(config); storage = driver.createStorage(); } StorageManager(); Storage getStorage(); StorageType getStorageType(); void registStorage(Class<?> storageDriverClass); }
@Test public void testLoadStorage() { StorageManager manager = new StorageManager(); }
MigrationVirtualNodeFinder { public String getTargetNodeOfVirtualNode(int vnode) { return index.get( vnode ); } MigrationVirtualNodeFinder(List<MigrationRoutePair> migrationRoutePairs); String getTargetNodeOfVirtualNode(int vnode); }
@Test public void testGetTargetNodeOfVirtualNode() { List<MigrationRoutePair> migrationRoutePairs = new ArrayList<MigrationRoutePair>(); for (int i = 0; i < 1000 ; i++) { MigrationRoutePair pair = new MigrationRoutePair(); pair.setVnode( i ); pair.setTargetPhysicalId("127.0.0.1"); migrationRoutePairs.add( pair ); } Mig...
ProgressComputer { public int getGrossProgress() { reentrantLock.lock(); try { return grossProgress; }finally { reentrantLock.unlock(); } } ProgressComputer(List<MigrationRoutePair> migrationRoutePairs); synchronized boolean completeOneVNode(String targetNodeId, Integer vnodeId); int getGrossProgress(); int getFinishCo...
@Test public void testGetGrossProgress() { List<MigrationRoutePair> migrationRoutePairs = new ArrayList<MigrationRoutePair>(); int t = 1, v = 10000 ; for (int i = 0; i < t; i++) { for (int j = 0; j < v; j++) { MigrationRoutePair pair = new MigrationRoutePair(j , "t"+i ); migrationRoutePairs.add( pair ); } } ProgressCom...
ConsistentReportServiceImpl implements ConsistentReportService { public Integer saveConsistentReport(ConsistentReportDO consistentReportDO) { return consistentReportDao.insert(consistentReportDO); } void setConsistentReportDao(ConsistentReportDao consistentReportDao); Integer saveConsistentReport(ConsistentReportDO co...
@Test public void testSaveConsistentReport() { }
SimulationTreeTableToModelConverter { public BPMNProcess convertTreeToModel(SushiTree<Object> tree){ this.tree = tree; BPMNStartEvent startEvent = new BPMNStartEvent(createID(), "Start", null); process.addBPMNElement(startEvent); BPMNEndEvent endEvent = new BPMNEndEvent(createID(), "End", null); process.addBPMNElement(...
@Test public void testConversion(){ SimulationTreeTableToModelConverter converter = new SimulationTreeTableToModelConverter(); BPMNProcess process = converter.convertTreeToModel(tree); assertTrue("Should be 14, but was " + process.getBPMNElementsWithOutSequenceFlows().size(), process.getBPMNElementsWithOutSequenceFlows...
BPMNParser extends AbstractXMLParser { public static BPMNProcess generateProcessFromXML(String filePath) { Document doc = readXMLDocument(filePath); return generateBPMNProcess(doc); } static BPMNProcess generateProcessFromXML(String filePath); }
@Test public void testComplexProcess() throws XPathExpressionException, ParserConfigurationException, SAXException, IOException{ BPMNProcess BPMNProcess = BPMNParser.generateProcessFromXML(complexfilePath); assertNotNull(BPMNProcess); assertTrue(BPMNProcess.getBPMNElementsWithOutSequenceFlows().size() == 21); assertTru...
XSDParser extends AbstractXMLParser { public static SushiEventType generateEventTypeFromXSD(String filePath, String eventTypeName) throws XMLParsingException { Document doc = readXMLDocument(filePath); if (doc == null) { throw new XMLParsingException("could not read XSD: " + filePath); } return generateEventType(doc, e...
@Test public void testXSDParsing() throws XPathExpressionException, ParserConfigurationException, SAXException, IOException{ SushiEventType eventType = null; try { eventType = XSDParser.generateEventTypeFromXSD(filePath, "EventTaxonomy"); } catch (XMLParsingException e) { fail(); } assertNotNull(eventType); }
XMLParser extends AbstractXMLParser { public static SushiEvent generateEventFromXML(String filePath) throws XMLParsingException { Document doc = readXMLDocument(filePath); return generateEvent(doc, null); } static SushiEvent generateEventFromXML(String filePath); static SushiEvent generateEventFromXML(String filePath,...
@Test public void testXMLParsing() throws XPathExpressionException, ParserConfigurationException, SAXException, IOException, XMLParsingException{ SushiEventType eventTyp = new SushiEventType("EventTaxonomy"); eventTyp.setXMLName("EventTaxonomy"); eventTyp.setTimestampName("timestamp"); eventTyp.save(); SushiEvent event...
BPM2XMLToSignavioXMLConverter extends AbstractXMLParser { public String generateSignavioXMLFromBPM2XML(){ SignavioBPMNProcess process = parseBPM2XML(); File file = new File(pathToCoreComponentsFolder + fileNameWithoutExtenxions + ".signavio.xml"); try { FileWriter writer = new FileWriter(file ,false); writer.write("<?x...
@Test public void testConversion(){ BPM2XMLToSignavioXMLConverter converter = new BPM2XMLToSignavioXMLConverter(emptyBpmn2FilePath); converter.generateSignavioXMLFromBPM2XML(); converter = new BPM2XMLToSignavioXMLConverter(startEventBpmn2FilePath); converter.generateSignavioXMLFromBPM2XML(); converter = new BPM2XMLToSi...
BPM2XMLToSignavioXMLConverter extends AbstractXMLParser { public SignavioBPMNProcess parseBPM2XML() { Document doc = readXMLDocument(bpm2FilePath); process = new SignavioBPMNProcess(); Node definitionNode = getDefinitionsElementFromBPM(doc); if(definitionNode != null){ process.addPropertyValue("targetnamespace", defini...
@Test public void testParsing(){ BPM2XMLToSignavioXMLConverter converter = new BPM2XMLToSignavioXMLConverter(emptyBpmn2FilePath); converter.parseBPM2XML(); }
Index implements Iterable<IndexItem<A,I>> { public static <A extends Annotation,I> Index<A,I> load(Class<A> annotation, Class<I> instanceType) throws IllegalArgumentException { return load(annotation, instanceType, Thread.currentThread().getContextClassLoader()); } private Index(Class<A> annotation, Class<I> instance,...
@Test public void staticallyKnownAnnotation() throws Exception { TestUtils.makeSource(src, "impl.C", "import " + Marker.class.getName().replace('$', '.') + ";", "@Marker(stuff=\"hello\")", "public class C {}"); TestUtils.runApt(src, null, clz, new File[] { new File(URI.create(Marker.class.getProtectionDomain().getCodeS...
AbstractClient { protected static void init() { keywordSet.add("-" + HOST_ARGS); keywordSet.add("-" + HELP_ARGS); keywordSet.add("-" + PORT_ARGS); keywordSet.add("-" + PASSWORD_ARGS); keywordSet.add("-" + USERNAME_ARGS); keywordSet.add("-" + ISO8601_ARGS); keywordSet.add("-" + MAX_PRINT_ROW_COUNT_ARGS); } static void ...
@Test public void testInit() { AbstractClient.init(); String[] keywords = {AbstractClient.HOST_ARGS, AbstractClient.HELP_ARGS, AbstractClient.PORT_ARGS, AbstractClient.PASSWORD_ARGS, AbstractClient.USERNAME_ARGS, AbstractClient.ISO8601_ARGS, AbstractClient.MAX_PRINT_ROW_COUNT_ARGS,}; for (String keyword : keywords) { i...
Pair { @Override public String toString() { return "<" + left + "," + right + ">"; } Pair(L l, R r); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); public L left; public R right; }
@Test public void testToString() { Pair<String, Integer> p1 = new Pair<String, Integer>("a", 123123); assertEquals("<a,123123>", p1.toString()); Pair<Float, Double> p2 = new Pair<Float, Double>(32.5f, 123.123d); assertEquals("<32.5,123.123>", p2.toString()); }
BytesUtils { public static byte[] intToBytes(int i) { return new byte[]{(byte) ((i >> 24) & 0xFF), (byte) ((i >> 16) & 0xFF), (byte) ((i >> 8) & 0xFF), (byte) (i & 0xFF)}; } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void intToBytes(int srcNum, byte[] result, int ...
@Test public void testIntToBytes() { int b = 123; byte[] bb = BytesUtils.intToBytes(b); int bf = BytesUtils.bytesToInt(bb); assertEquals("testBytesToFloat", b, bf); }
BytesUtils { public static byte[] floatToBytes(float x) { byte[] b = new byte[4]; int l = Float.floatToIntBits(x); for (int i = 3; i >= 0; i--) { b[i] = new Integer(l).byteValue(); l = l >> 8; } return b; } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void intToByte...
@Test public void testFloatToBytes() throws Exception { float b = 25.0f; byte[] bb = BytesUtils.floatToBytes(b); float bf = BytesUtils.bytesToFloat(bb); assertEquals("testBytesToFloat", b, bf, CommonTestConstant.float_min_delta); }
BytesUtils { public static byte[] boolToBytes(boolean x) { byte[] b = new byte[1]; if (x) { b[0] = 1; } else { b[0] = 0; } return b; } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void intToBytes(int srcNum, byte[] result, int pos, int width); static byte[] intToTwo...
@Test public void testBoolToBytes() throws Exception { boolean b = true; byte[] bb = BytesUtils.boolToBytes(b); boolean bf = BytesUtils.bytesToBool(bb); assertEquals("testBoolToBytes", b, bf); }
BytesUtils { public static byte[] longToBytes(long num) { return longToBytes(num, 8); } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void intToBytes(int srcNum, byte[] result, int pos, int width); static byte[] intToTwoBytes(int i); static int twoBytesToInt(byte[] r...
@Test public void testlongToBytes() { long lNum = 32143422454243342L; long iNum = 1032423424L; long lSNum = 10; assertEquals(lNum, BytesUtils.bytesToLong(BytesUtils.longToBytes(lNum, 8), 8)); assertEquals(iNum, BytesUtils.bytesToLong(BytesUtils.longToBytes(iNum, 8), 8)); assertEquals(iNum, BytesUtils.bytesToLong(BytesU...
BytesUtils { public static long readLong(InputStream in) throws IOException { byte[] b = safeReadInputStreamToBytes(8, in); return BytesUtils.bytesToLong(b); } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void intToBytes(int srcNum, byte[] result, int pos, int width...
@Test public void readLongTest() throws IOException { long l = 32143422454243342L; byte[] bs = BytesUtils.longToBytes(l); InputStream in = new ByteArrayInputStream(bs); assertEquals(l, BytesUtils.readLong(in)); } @Test public void testReadLong() throws IOException { long l = r.nextLong(); byte[] bs = BytesUtils.longToB...
BytesUtils { public static byte[] doubleToBytes(double data) { byte[] bytes = new byte[8]; long value = Double.doubleToLongBits(data); for (int i = 7; i >= 0; i--) { bytes[i] = new Long(value).byteValue(); value = value >> 8; } return bytes; } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] des...
@Test public void testDoubleToBytes() { double b1 = 2745687.1253123d; byte[] ret = BytesUtils.doubleToBytes(b1); double rb1 = BytesUtils.bytesToDouble(ret); assertEquals(b1, rb1, CommonTestConstant.float_min_delta); }
BytesUtils { public static byte[] stringToBytes(String str) { try { return str.getBytes(TSFileConfig.STRING_ENCODING); } catch (UnsupportedEncodingException e) { LOG.error("catch UnsupportedEncodingException {}", str, e); return null; } } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, in...
@Test public void testStringToBytes() { String b = "lqfkgv12KLDJSL1@#%"; byte[] ret = BytesUtils.stringToBytes(b); String rb1 = BytesUtils.bytesToString(ret); assertTrue(b.equals(rb1)); }
BytesUtils { public static byte[] concatByteArray(byte[] a, byte[] b) { byte[] c = new byte[a.length + b.length]; System.arraycopy(a, 0, c, 0, a.length); System.arraycopy(b, 0, c, a.length, b.length); return c; } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void int...
@Test public void testConcatByteArray() { List<byte[]> list = new ArrayList<byte[]>(); float f1 = 12.4f; boolean b1 = true; list.add(BytesUtils.floatToBytes(f1)); list.add(BytesUtils.boolToBytes(b1)); byte[] ret = BytesUtils.concatByteArray(list.get(0), list.get(1)); float rf1 = BytesUtils.bytesToFloat(ret, 0); boolean...
BytesUtils { public static byte[] concatByteArrayList(List<byte[]> list) { int size = list.size(); int len = 0; for (byte[] cs : list) { len += cs.length; } byte[] result = new byte[len]; int pos = 0; for (int i = 0; i < size; i++) { int l = list.get(i).length; System.arraycopy(list.get(i), 0, result, pos, l); pos += l...
@Test public void testConcatByteArrayList() { List<byte[]> list = new ArrayList<byte[]>(); float f1 = 12.4f; boolean b1 = true; int i1 = 12; list.add(BytesUtils.floatToBytes(f1)); list.add(BytesUtils.boolToBytes(b1)); list.add(BytesUtils.intToBytes(i1)); byte[] ret = BytesUtils.concatByteArrayList(list); float rf1 = By...
AbstractClient { protected static String checkRequiredArg(String arg, String name, CommandLine commandLine, boolean isRequired, String defaultValue) throws ArgsErrorException { String str = commandLine.getOptionValue(arg); if (str == null) { if (isRequired) { String msg = String .format("%s: Required values for option ...
@Test public void testCheckRequiredArg() throws ParseException, ArgsErrorException { Options options = AbstractClient.createOptions(); CommandLineParser parser = new DefaultParser(); String[] args = new String[]{"-u", "user1"}; CommandLine commandLine = parser.parse(options, args); String str = AbstractClient .checkReq...
BytesUtils { public static byte[] subBytes(byte[] src, int start, int length) { if ((start + length) > src.length) { return null; } if (length <= 0) { return null; } byte[] result = new byte[length]; for (int i = 0; i < length; i++) { result[i] = src[start + i]; } return result; } static byte[] intToBytes(int i); stat...
@Test public void testSubBytes() throws IOException { List<byte[]> list = new ArrayList<byte[]>(); float f1 = 12.4f; boolean b1 = true; int i1 = 12; list.add(BytesUtils.floatToBytes(f1)); list.add(BytesUtils.boolToBytes(b1)); list.add(BytesUtils.intToBytes(i1)); byte[] ret = BytesUtils.concatByteArrayList(list); boolea...
BytesUtils { public static int getByteN(byte data, int offset) { offset %= 8; if ((data & (1 << (7 - offset))) != 0) { return 1; } else { return 0; } } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void intToBytes(int srcNum, byte[] result, int pos, int width); stati...
@Test public void testGetByteN() { byte src = 120; byte dest = 0; for (int i = 0; i < 64; i++) { int a = BytesUtils.getByteN(src, i); dest = BytesUtils.setByteN(dest, i, a); } assertEquals(src, dest); }
BytesUtils { public static int getLongN(long data, int offset) { offset %= 64; if ((data & (1L << (offset))) != 0) { return 1; } else { return 0; } } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void intToBytes(int srcNum, byte[] result, int pos, int width); static ...
@Test public void testGetLongN() { long src = (long) Math.pow(2, 33); long dest = 0; for (int i = 0; i < 64; i++) { int a = BytesUtils.getLongN(src, i); dest = BytesUtils.setLongN(dest, i, a); } assertEquals(src, dest); }
BytesUtils { public static int getIntN(int data, int offset) { offset %= 32; if ((data & (1 << (offset))) != 0) { return 1; } else { return 0; } } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void intToBytes(int srcNum, byte[] result, int pos, int width); static byt...
@Test public void testGetIntN() { int src = 54243342; int dest = 0; for (int i = 0; i < 32; i++) { int a = BytesUtils.getIntN(src, i); dest = BytesUtils.setIntN(dest, i, a); } assertEquals(src, dest); }
BytesUtils { public static int readInt(InputStream in) throws IOException { byte[] b = safeReadInputStreamToBytes(4, in); return BytesUtils.bytesToInt(b); } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void intToBytes(int srcNum, byte[] result, int pos, int width); ...
@Test public void testReadInt() throws IOException { int l = r.nextInt(); byte[] bs = BytesUtils.intToBytes(l); InputStream in = new ByteArrayInputStream(bs); assertEquals(l, BytesUtils.readInt(in)); }
BytesUtils { public static float readFloat(InputStream in) throws IOException { byte[] b = safeReadInputStreamToBytes(4, in); return BytesUtils.bytesToFloat(b); } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void intToBytes(int srcNum, byte[] result, int pos, int wi...
@Test public void testReadFloat() throws IOException { float l = r.nextFloat(); byte[] bs = BytesUtils.floatToBytes(l); InputStream in = new ByteArrayInputStream(bs); assertEquals(l, BytesUtils.readFloat(in), CommonTestConstant.float_min_delta); }
BytesUtils { public static double readDouble(InputStream in) throws IOException { byte[] b = safeReadInputStreamToBytes(8, in); return BytesUtils.bytesToDouble(b); } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void intToBytes(int srcNum, byte[] result, int pos, int...
@Test public void testReadDouble() throws IOException { double l = r.nextDouble(); byte[] bs = BytesUtils.doubleToBytes(l); InputStream in = new ByteArrayInputStream(bs); assertEquals(l, BytesUtils.readDouble(in), CommonTestConstant.double_min_delta); }
BytesUtils { public static boolean readBool(InputStream in) throws IOException { byte[] b = safeReadInputStreamToBytes(1, in); return BytesUtils.bytesToBool(b); } static byte[] intToBytes(int i); static byte[] intToBytes(int i, byte[] desc, int offset); static void intToBytes(int srcNum, byte[] result, int pos, int wi...
@Test public void testReadBool() throws IOException { boolean l = r.nextBoolean(); byte[] bs = BytesUtils.boolToBytes(l); InputStream in = new ByteArrayInputStream(bs); assertEquals(l, BytesUtils.readBool(in)); }
StringContainer { public String getSubString(int index) { int realIndex = index >= 0 ? index : count + index; if (realIndex < 0 || realIndex >= count) { throw new IndexOutOfBoundsException( "Index: " + index + ", Real Index: " + realIndex + ", Size: " + count); } if (realIndex < reverseList.size()) { return reverseList...
@Test public void testGetSubString() { StringContainer a = new StringContainer(); try { a.getSubString(0); } catch (Exception e) { assertTrue(e instanceof IndexOutOfBoundsException); } a.addHead("a", "bbb", "cc"); assertEquals("a", a.getSubString(0)); assertEquals("cc", a.getSubString(-1)); assertEquals("bbb", a.getSub...
AbstractClient { protected static String[] removePasswordArgs(String[] args) { int index = -1; for (int i = 0; i < args.length; i++) { if (args[i].equals("-" + PASSWORD_ARGS)) { index = i; break; } } if (index >= 0) { if ((index + 1 >= args.length) || (index + 1 < args.length && keywordSet .contains(args[index + 1]))) ...
@Test public void testRemovePasswordArgs() { AbstractClient.init(); String[] input = new String[]{"-h", "127.0.0.1", "-p", "6667", "-u", "root", "-pw", "root"}; String[] res = new String[]{"-h", "127.0.0.1", "-p", "6667", "-u", "root", "-pw", "root"}; isTwoStringArrayEqual(res, AbstractClient.removePasswordArgs(input))...
StringContainer { public StringContainer getSubStringContainer(int start, int end) { int realStartIndex = start >= 0 ? start : count + start; int realEndIndex = end >= 0 ? end : count + end; if (realStartIndex < 0 || realStartIndex >= count) { throw new IndexOutOfBoundsException( "start Index: " + start + ", Real start...
@Test public void testGetSubStringContainer() { StringContainer a = new StringContainer(); try { a.getSubStringContainer(0, 1); } catch (Exception e) { assertTrue(e instanceof IndexOutOfBoundsException); } a.addTail("a", "bbb", "cc"); assertEquals("", a.getSubStringContainer(1, 0).toString()); assertEquals("a", a.getSu...
StringContainer { @Override public int hashCode() { final int prime = 31; int result = 1; if (joinSeparator != null) { result = prime * result + joinSeparator.hashCode(); } for (String string : reverseList) { result = prime * result + ((string == null) ? 0 : string.hashCode()); } for (String string : sequenceList) { re...
@Test public void testHashCode() { StringContainer c1 = new StringContainer(","); c1.addHead("a", "b", "c123"); c1.addTail("a", "12", "c"); c1.addTail("1284736", "b", "c"); StringContainer c2 = new StringContainer("."); c2.addHead("a", "b", "c123"); c2.addTail("a", "12", "c"); c2.addTail("1284736", "b", "c"); StringCon...
MetadataQuerierByFileImpl implements MetadataQuerier { @Override public List<ChunkMetaData> getChunkMetaDataList(Path path) throws IOException { return chunkMetaDataCache.get(path); } MetadataQuerierByFileImpl(TsFileSequenceReader tsFileReader); @Override List<ChunkMetaData> getChunkMetaDataList(Path path); @Override T...
@Test public void test() throws IOException { fileReader = new TsFileSequenceReader(FILE_PATH); MetadataQuerierByFileImpl metadataQuerierByFile = new MetadataQuerierByFileImpl(fileReader); List<ChunkMetaData> chunkMetaDataList = metadataQuerierByFile .getChunkMetaDataList(new Path("d2.s1")); for (ChunkMetaData chunkMet...
Path { public boolean startWith(String prefix) { return prefix != null && fullPath.startsWith(prefix); } Path(StringContainer pathSc); Path(String pathSc); Path(String[] pathSc); Path(String device, String measurement); static Path mergePath(Path prefix, Path suffix); static Path addPrefixPath(Path src, String prefi...
@Test public void startWith() throws Exception { Path path = new Path("a.b.c"); assertTrue(path.startWith(new Path(""))); assertTrue(path.startWith(new Path("a"))); assertTrue(path.startWith(new Path("a.b.c"))); }
Path { public static Path mergePath(Path prefix, Path suffix) { StringContainer sc = new StringContainer(SystemConstant.PATH_SEPARATOR); sc.addTail(prefix); sc.addTail(suffix); return new Path(sc); } Path(StringContainer pathSc); Path(String pathSc); Path(String[] pathSc); Path(String device, String measurement); st...
@Test public void mergePath() throws Exception { Path prefix = new Path("a.b.c"); Path suffix = new Path("d.e"); Path suffix1 = new Path(""); testPath(Path.mergePath(prefix, suffix), "a.b.c.d", "e", "a.b.c.d.e"); testPath(Path.mergePath(prefix, suffix1), "a.b", "c", "a.b.c"); }
Path { public static Path replace(String srcPrefix, Path descPrefix) { if ("".equals(srcPrefix) || descPrefix.startWith(srcPrefix)) { return descPrefix; } int prefixSize = srcPrefix.split(SystemConstant.PATH_SEPARATER_NO_REGEX).length; String[] descArray = descPrefix.fullPath.split(SystemConstant.PATH_SEPARATER_NO_REGE...
@Test public void replace() throws Exception { Path src = new Path("a.b.c"); Path rep1 = new Path(""); Path rep2 = new Path("d"); Path rep3 = new Path("d.e.f"); Path rep4 = new Path("d.e.f.g"); testPath(Path.replace(rep1, src), "a.b", "c", "a.b.c"); testPath(Path.replace(rep2, src), "d.b", "c", "d.b.c"); testPath(Path....
ReadOnlyTsFile { public QueryDataSet query(QueryExpression queryExpression) throws IOException { return tsFileExecutor.execute(queryExpression); } ReadOnlyTsFile(TsFileSequenceReader fileReader); QueryDataSet query(QueryExpression queryExpression); void close(); }
@Test public void queryTest() throws IOException { Filter filter = TimeFilter.lt(1480562618100L); Filter filter2 = ValueFilter.gt(new Binary("dog")); Filter filter3 = FilterFactory .and(TimeFilter.gtEq(1480562618000L), TimeFilter.ltEq(1480562618100L)); IExpression IExpression = BinaryExpression .or(BinaryExpression.and...
IoTDBDatabaseMetadata implements DatabaseMetaData { public String getMetadataInJson() throws SQLException { try { return getMetadataInJsonFunc(); } catch (TException e) { boolean flag = connection.reconnect(); this.client = connection.client; if (flag) { try { return getMetadataInJsonFunc(); } catch (TException e2) { t...
@SuppressWarnings("resource") @Test public void ShowTimeseriesInJson() throws Exception { String metadataInJson = "=== Timeseries Tree ===\n" + "\n" + "root:{\n" + " vehicle:{\n" + " d0:{\n" + " s0:{\n" + " DataType: INT32,\n" + " Encoding: RLE,\n" + " args: {},\n" + " StorageGroup: root.vehicle \n" + " },\n" + " s1:{\...
IoTDBPrepareStatement extends IoTDBStatement implements PreparedStatement { @Override public boolean execute() throws SQLException { return super.execute(createCompleteSql(sql, parameters)); } IoTDBPrepareStatement(IoTDBConnection connection, Iface client, TS_SessionHandle sessionHandle, String sql, ZoneId ...
@SuppressWarnings("resource") @Test public void testNonParameterized() throws Exception { String sql = "SELECT status, temperature FROM root.ln.wf01.wt01 WHERE temperature < 24 and time > 2017-11-1 0:13:00"; IoTDBPrepareStatement ps = new IoTDBPrepareStatement(connection, client, sessHandle, sql, zoneId); ps.execute();...
AbstractClient { protected static OperationResult handleInputInputCmd(String cmd, IoTDBConnection connection) { String specialCmd = cmd.toLowerCase().trim(); if (specialCmd.equals(QUIT_COMMAND) || specialCmd.equals(EXIT_COMMAND)) { System.out.println(specialCmd + " normally"); return OperationResult.RETURN_OPER; } if (...
@Test public void testHandleInputInputCmd() { assertEquals(AbstractClient.handleInputInputCmd(AbstractClient.EXIT_COMMAND, connection), OperationResult.RETURN_OPER); assertEquals(AbstractClient.handleInputInputCmd(AbstractClient.QUIT_COMMAND, connection), OperationResult.RETURN_OPER); assertEquals( AbstractClient.handl...
IoTDBStatement implements Statement { @Override public boolean execute(String sql) throws SQLException { checkConnection("execute"); isClosed = false; try { return executeSQL(sql); } catch (TException e) { boolean flag = connection.reconnect(); reInit(); if (flag) { try { return executeSQL(sql); } catch (TException e2)...
@SuppressWarnings("resource") @Test(expected = SQLException.class) public void testExecuteSQL1() throws SQLException { IoTDBStatement stmt = new IoTDBStatement(connection, client, sessHandle, zoneID); stmt.execute("show timeseries"); }
IoTDBStatement implements Statement { @Override public int getFetchSize() throws SQLException { checkConnection("getFetchSize"); return fetchSize; } IoTDBStatement(IoTDBConnection connection, TSIService.Iface client, TS_SessionHandle sessionHandle, int fetchSize, ZoneId zoneId); IoTDBStatement(IoTDBConnect...
@SuppressWarnings("resource") @Test public void testSetFetchSize3() throws SQLException { final int fetchSize = 10000; IoTDBStatement stmt = new IoTDBStatement(connection, client, sessHandle, fetchSize, zoneID); assertEquals(fetchSize, stmt.getFetchSize()); }
IoTDBStatement implements Statement { @Override public void setFetchSize(int fetchSize) throws SQLException { checkConnection("setFetchSize"); if (fetchSize < 0) { throw new SQLException(String.format("fetchSize %d must be >= 0!", fetchSize)); } this.fetchSize = fetchSize == 0 ? Config.fetchSize : fetchSize; } IoTDBSta...
@SuppressWarnings("resource") @Test(expected = SQLException.class) public void testSetFetchSize4() throws SQLException { IoTDBStatement stmt = new IoTDBStatement(connection, client, sessHandle, zoneID); stmt.setFetchSize(-1); }
IoTDBStatement implements Statement { @Override public void setMaxRows(int num) throws SQLException { checkConnection("setMaxRows"); if (num < 0) { throw new SQLException(String.format("maxRows %d must be >= 0!", num)); } this.maxRows = num; } IoTDBStatement(IoTDBConnection connection, TSIService.Iface client, TS...
@SuppressWarnings("resource") @Test(expected = SQLException.class) public void testSetMaxRows2() throws SQLException { IoTDBStatement stmt = new IoTDBStatement(connection, client, sessHandle, zoneID); stmt.setMaxRows(-1); }
IoTDBMetadataResultMetadata implements ResultSetMetaData { @Override public int getColumnCount() throws SQLException { if (showLabels == null || showLabels.length == 0) { throw new SQLException("No column exists"); } return showLabels.length; } IoTDBMetadataResultMetadata(String[] showLabels); @Override boolean isWrapp...
@Test public void testGetColumnCount() throws SQLException { boolean flag = false; try { metadata = new IoTDBMetadataResultMetadata(null); assertEquals((long) metadata.getColumnCount(), 0); } catch (Exception e) { flag = true; } assertEquals(flag, true); flag = false; try { String[] nullArray = {}; metadata = new IoTDB...
IoTDBMetadataResultMetadata implements ResultSetMetaData { @Override public String getColumnName(int column) throws SQLException { return getColumnLabel(column); } IoTDBMetadataResultMetadata(String[] showLabels); @Override boolean isWrapperFor(Class<?> arg0); @Override T unwrap(Class<T> arg0); @Override String getCata...
@Test public void testGetColumnName() throws SQLException { boolean flag = false; metadata = new IoTDBMetadataResultMetadata(null); try { metadata.getColumnName(1); } catch (Exception e) { flag = true; } assertEquals(flag, true); try { String[] nullArray = {}; metadata = new IoTDBMetadataResultMetadata(nullArray); meta...
IoTDBResultMetadata implements ResultSetMetaData { @Override public int getColumnCount() throws SQLException { if (columnInfoList == null || columnInfoList.size() == 0) { throw new SQLException("No column exists"); } return columnInfoList.size(); } IoTDBResultMetadata(List<String> columnInfoList, String operationType, ...
@Test public void testGetColumnCount() throws SQLException { metadata = new IoTDBResultMetadata(null, null, null); boolean flag = false; try { metadata.getColumnCount(); } catch (Exception e) { flag = true; } assertEquals(flag, true); List<String> columnInfoList = new ArrayList<>(); flag = false; try { metadata = new I...
IoTDBResultMetadata implements ResultSetMetaData { @Override public String getColumnName(int column) throws SQLException { return getColumnLabel(column); } IoTDBResultMetadata(List<String> columnInfoList, String operationType, List<String> columnTypeList); @Override boolean isWrapperFor(Class<?> arg0); @Override ...
@Test public void testGetColumnName() throws SQLException { metadata = new IoTDBResultMetadata(null, null, null); boolean flag = false; try { metadata.getColumnName(1); } catch (Exception e) { flag = true; } assertEquals(flag, true); List<String> columnInfoList = new ArrayList<>(); metadata = new IoTDBResultMetadata(co...
IoTDBResultMetadata implements ResultSetMetaData { @Override public int getColumnType(int column) throws SQLException { if (columnInfoList == null || columnInfoList.size() == 0) { throw new SQLException("No column exists"); } if (column > columnInfoList.size()) { throw new SQLException(String.format("column %d does not...
@Test public void testGetColumnType() throws SQLException { metadata = new IoTDBResultMetadata(null, null, null); boolean flag = false; try { metadata.getColumnType(1); } catch (Exception e) { flag = true; } assertEquals(flag, true); List<String> columnInfoList = new ArrayList<>(); metadata = new IoTDBResultMetadata(co...
IoTDBResultMetadata implements ResultSetMetaData { @Override public String getColumnTypeName(int arg0) throws SQLException { return operationType; } IoTDBResultMetadata(List<String> columnInfoList, String operationType, List<String> columnTypeList); @Override boolean isWrapperFor(Class<?> arg0); @Override T unwra...
@Test public void testGetColumnTypeName() throws SQLException { String operationType = "sum"; metadata = new IoTDBResultMetadata(null, operationType, null); assertEquals(metadata.getColumnTypeName(1), operationType); }
FloatDecoder extends Decoder { @Override public float readFloat(ByteBuffer buffer) { readMaxPointValue(buffer); int value = decoder.readInt(buffer); double result = value / maxPointValue; return (float) result; } FloatDecoder(TSEncoding encodingType, TSDataType dataType); @Override float readFloat(ByteBuffer buffer); @...
@Test public void test() throws Exception { float value = 7.101f; Encoder encoder = new FloatEncoder(TSEncoding.RLE, TSDataType.FLOAT, 3); ByteArrayOutputStream baos = new ByteArrayOutputStream(); encoder.encode(value, baos); encoder.flush(baos); encoder.encode(value + 2, baos); encoder.flush(baos); ByteBuffer buffer =...
IoTDBConnection implements Connection { public void setTimeZone(String zoneId) throws TException, IoTDBSQLException { TSSetTimeZoneReq req = new TSSetTimeZoneReq(zoneId); TSSetTimeZoneResp resp = client.setTimeZone(req); Utils.verifySuccess(resp.getStatus()); this.zoneId = ZoneId.of(zoneId); } IoTDBConnection(); IoTDB...
@Test public void testSetTimeZone() throws TException, IoTDBSQLException { String timeZone = "Asia/Shanghai"; when(client.setTimeZone(any(TSSetTimeZoneReq.class))) .thenReturn(new TSSetTimeZoneResp(Status_SUCCESS)); connection.client = client; connection.setTimeZone(timeZone); assertEquals(connection.getTimeZone(), tim...
IoTDBConnection implements Connection { public String getTimeZone() throws TException, IoTDBSQLException { if (zoneId != null) { return zoneId.toString(); } TSGetTimeZoneResp resp = client.getTimeZone(); Utils.verifySuccess(resp.getStatus()); return resp.getTimeZone(); } IoTDBConnection(); IoTDBConnection(String url, ...
@Test public void testGetTimeZone() throws IoTDBSQLException, TException { String timeZone = "GMT+:08:00"; when(client.getTimeZone()).thenReturn(new TSGetTimeZoneResp(Status_SUCCESS, timeZone)); connection.client = client; assertEquals(connection.getTimeZone(), timeZone); }