src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
ByteUtils { public static byte[] floatToBytesBE(float f, byte[] bytes, int off) { return intToBytesBE(Float.floatToIntBits(f), bytes, off); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); static int by...
@Test public void testFloatToBytesBE() { assertArrayEquals(FLOAT_PI_BE , ByteUtils.floatToBytesBE((float) Math.PI, new byte[4], 0)); }
ByteUtils { public static byte[] floatToBytesLE(float f, byte[] bytes, int off) { return intToBytesLE(Float.floatToIntBits(f), bytes, off); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); static int by...
@Test public void testFloatToBytesLE() { assertArrayEquals(FLOAT_PI_LE , ByteUtils.floatToBytesLE((float) Math.PI, new byte[4], 0)); }
ByteUtils { public static byte[] doubleToBytesBE(double d, byte[] bytes, int off) { return longToBytesBE(Double.doubleToLongBits(d), bytes, off); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); static ...
@Test public void testDoubleToBytesBE() { assertArrayEquals(DOUBLE_PI_BE , ByteUtils.doubleToBytesBE(Math.PI, new byte[8], 0)); }
ByteUtils { public static byte[] doubleToBytesLE(double d, byte[] bytes, int off) { return longToBytesLE(Double.doubleToLongBits(d), bytes, off); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); static ...
@Test public void testDoubleToBytesLE() { assertArrayEquals(DOUBLE_PI_LE , ByteUtils.doubleToBytesLE(Math.PI, new byte[8], 0)); }
ByteUtils { public static byte[][] swapShorts(byte bs[][]) { int carry = 0; for (int i = 0; i < bs.length; i++) { byte[] b = bs[i]; if (carry != 0) swapLastFirst(bs[i-1], b); int len = b.length - carry; swapShorts(b, carry, len & ~1); carry = len & 1; } return bs; } static int bytesToVR(byte[] bytes, int off); static ...
@Test public void testSwapShorts() { assertArrayEquals(TAG_PIXEL_DATA_LE , ByteUtils.swapShorts(TAG_PIXEL_DATA_BE.clone(), 0, TAG_PIXEL_DATA_BE.length)); }
ByteUtils { public static byte[] swapInts(byte b[], int off, int len) { checkLength(len, 4); for (int i = off, n = off + len; i < n; i += 4) { swap(b, i, i+3); swap(b, i+1, i+2); } return b; } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int by...
@Test public void testSwapInts() { assertArrayEquals(FLOAT_PI_LE , ByteUtils.swapInts(FLOAT_PI_BE.clone(), 0, FLOAT_PI_BE.length)); }
ByteUtils { public static byte[] swapLongs(byte b[], int off, int len) { checkLength(len, 8); for (int i = off, n = off + len; i < n; i += 8) { swap(b, i, i+7); swap(b, i+1, i+6); swap(b, i+2, i+5); swap(b, i+3, i+4); } return b; } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int...
@Test public void testSwapLongs() { assertArrayEquals(DOUBLE_PI_LE , ByteUtils.swapLongs(DOUBLE_PI_BE.clone(), 0, DOUBLE_PI_BE.length)); }
DicomInputStream extends FilterInputStream implements DicomInputHandler, BulkDataCreator { public Attributes readDataset(int len, int stopTag) throws IOException { handler.startDataset(this); readFileMetaInformation(); Attributes attrs = new Attributes(bigEndian, 64); readAttributes(attrs, len, stopTag); attrs.trimToSi...
@Test(expected = EOFException.class) public void testNoOutOfMemoryErrorOnInvalidLength() throws IOException { byte[] b = { 8, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 'e', 'v', 'i', 'l', 'l', 'e', 'n', 'g', 'h' }; try ( DicomInputStream in = new DicomInputStream(new ByteArrayInputStream(b))) { in.readDataset(-1, -1); } }
DicomOutputStream extends FilterOutputStream { public void writeCommand(Attributes cmd) throws IOException { if (explicitVR || bigEndian) throw new IllegalStateException("explicitVR=" + explicitVR + ", bigEndian=" + bigEndian); cmd.writeGroupTo(this, Tag.CommandGroupLength); } DicomOutputStream(OutputStream out, String...
@Test public void testWriteCommand() throws IOException { DicomOutputStream out = new DicomOutputStream( new FileOutputStream(file), UID.ImplicitVRLittleEndian); try { out.writeCommand(cechorq()); } finally { out.close(); } assertEquals(4, readAttributes().size()); }
AttributeSelector implements Serializable { public boolean matches(List<ItemPointer> itemPointers, String privateCreator, int tag) { int level; if (tag != this.tag || !Objects.equals(privateCreator, this.privateCreator) || (itemPointers.size() != (level = level()))) { return false; } for (int i = 0; i < level; i++) { I...
@Test public void testMatches() { ItemPointer ip = new ItemPointer(Tag.RequestAttributesSequence); AttributeSelector selector = new AttributeSelector(Tag.StudyInstanceUID, null, ip); assertTrue(selector.matches(Collections.singletonList(ip), null, Tag.StudyInstanceUID)); }
DicomOutputStream extends FilterOutputStream { public void writeDataset(Attributes fmi, Attributes dataset) throws IOException { if (fmi != null) { writeFileMetaInformation(fmi); switchTransferSyntax(fmi.getString(Tag.TransferSyntaxUID, null)); } if (dataset.bigEndian() != bigEndian || encOpts.groupLength || !encOpts.u...
@Test public void testWriteDataset() throws IOException { DicomOutputStream out = new DicomOutputStream(file); } @Test public void testWriteDeflatedEvenLength() throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); try (DicomOutputStream dos = new DicomOutputStream( out, UID.DeflatedExplicitVRLi...
DicomOutputStream extends FilterOutputStream { public final void setEncodingOptions(DicomEncodingOptions encOpts) { if (encOpts == null) throw new NullPointerException(); this.encOpts = encOpts; } DicomOutputStream(OutputStream out, String tsuid); DicomOutputStream(File file); final void setPreamble(byte[] preamble); ...
@Test public void testWriteDatasetWithGroupLength() throws IOException { DicomOutputStream out = new DicomOutputStream(file); out.setEncodingOptions( new DicomEncodingOptions(true, true, false, true, false)); testWriteDataset(out, UID.ExplicitVRLittleEndian); } @Test public void testWriteDatasetWithoutUndefLength() thr...
DicomOutputStream extends FilterOutputStream { public void close() throws IOException { try { finish(); } catch (IOException ignored) { } super.close(); } DicomOutputStream(OutputStream out, String tsuid); DicomOutputStream(File file); final void setPreamble(byte[] preamble); final boolean isExplicitVR(); final boolea...
@Test public void testSerializeDataset() throws Exception { ObjectOutputStream out = new ObjectOutputStream( new FileOutputStream(file)); try { out.writeObject(dataset()); out.writeUTF("END"); } finally { out.close(); } deserializeAttributes(); }
DicomOutputStream extends FilterOutputStream { public void writeFileMetaInformation(Attributes fmi) throws IOException { if (!explicitVR || bigEndian || countingOutputStream != null) throw new IllegalStateException("explicitVR=" + explicitVR + ", bigEndian=" + bigEndian + ", deflated=" + (countingOutputStream != null))...
@Test(expected = IllegalStateException.class) public void testWriteFMIDeflated() throws IOException { try (DicomOutputStream out = new DicomOutputStream( new ByteArrayOutputStream(), UID.DeflatedExplicitVRLittleEndian)) { out.writeFileMetaInformation( Attributes.createFileMetaInformation(UIDUtils.createUID(), UID.CTIma...
RecordFactory { public RecordType getRecordType(String cuid) { if (cuid == null) throw new NullPointerException(); lazyLoadDefaultConfiguration(); RecordType recordType = recordTypes.get(cuid); return recordType != null ? recordType : RecordType.PRIVATE; } void loadDefaultConfiguration(); void loadConfiguration(String...
@Test public void testGetRecordType() { RecordFactory f = new RecordFactory(); assertEquals(RecordType.IMAGE, f.getRecordType(UID.SecondaryCaptureImageStorage)); }
FindSCU { static void mergeKeys(Attributes attrs, Attributes keys) { try { attrs.accept(new MergeNested(keys), false); } catch (Exception e) { throw new RuntimeException(e); } attrs.addAll(keys); } FindSCU(); final void setPriority(int priority); final void setInformationModel(InformationModel model, String[] tss, ...
@Test public void mergeNestedKeys() throws Exception { Attributes attrs = withSSA(returnKeys()); FindSCU.mergeKeys(attrs, withSSA(matchingKeys())); assertEquals(mergedKeys(), attrs.getNestedDataset(Tag.ScheduledStepAttributesSequence)); }
Device implements Serializable { public void reconfigure(Device from) throws IOException, GeneralSecurityException { setDeviceAttributes(from); reconfigureConnections(from); reconfigureApplicationEntities(from); reconfigureWebApplications(from); reconfigureKeycloakClients(from); reconfigureDeviceExtensions(from); } Dev...
@Test public void testReconfigure() throws Exception { Device d1 = createDevice("test", "AET1"); Device d2 = createDevice("test", "AET2"); d1.reconfigure(d2); ApplicationEntity ae = d1.getApplicationEntity("AET2"); assertNotNull(ae); List<Connection> conns = ae.getConnections(); assertEquals(1, conns.size()); }
SpecificCharacterSet { public byte[] encode(String val, String delimiters) { return codecs[0].encode(val); } protected SpecificCharacterSet(Codec[] codecs, String... codes); static SpecificCharacterSet getDefaultCharacterSet(); static void setDefaultCharacterSet(String code); static void setCharsetNameMapping(String c...
@Test public void testEncodeGermanPersonName() { assertArrayEquals(GERMAN_PERSON_NAME_BYTE, iso8859_1().encode(GERMAN_PERSON_NAME, PN_DELIMS)); } @Test public void testEncodeFrenchPersonName() { assertArrayEquals(FRENCH_PERSON_NAME_BYTE, iso8859_1().encode(FRENCH_PERSON_NAME, PN_DELIMS)); } @Test public void testEncode...
SpecificCharacterSet { public String decode(byte[] val) { return codecs[0].decode(val, 0, val.length); } protected SpecificCharacterSet(Codec[] codecs, String... codes); static SpecificCharacterSet getDefaultCharacterSet(); static void setDefaultCharacterSet(String code); static void setCharsetNameMapping(String code,...
@Test public void testDecodeGermanPersonName() { assertEquals(GERMAN_PERSON_NAME, iso8859_1().decode(GERMAN_PERSON_NAME_BYTE)); } @Test public void testDecodeFrenchPersonName() { assertEquals(FRENCH_PERSON_NAME, iso8859_1().decode(FRENCH_PERSON_NAME_BYTE)); } @Test public void testDecodeRussianPersonName() { assertEqua...
JSONWriter implements DicomInputHandler { public void write(Attributes attrs) { final SpecificCharacterSet cs = attrs.getSpecificCharacterSet(); gen.writeStartObject(); try { attrs.accept(new Attributes.Visitor(){ @Override public boolean visit(Attributes attrs, int tag, VR vr, Object value) throws Exception { writeAtt...
@Test public void test() { Attributes dataset = new Attributes(); dataset.setString(Tag.SpecificCharacterSet, VR.CS, null, "ISO 2022 IR 87"); dataset.setString(Tag.ImageType, VR.CS, "DERIVED", "PRIMARY"); Attributes item = new Attributes(2); dataset.newSequence(Tag.SourceImageSequence, 1).add(item); item.setString(Tag....
LdapHL7Configuration extends LdapDicomConfigurationExtension implements HL7Configuration { @Override public HL7Application findHL7Application(String name) throws ConfigurationException { Device device = config.findDevice( "(&(objectclass=hl7Application)(hl7ApplicationName=" + name + "))", name); HL7DeviceExtension hl7E...
@Test public void testPersist() throws Exception { try { config.removeDevice("Test-Device-1", null); } catch (ConfigurationNotFoundException e) {} Device device = createDevice("Test-Device-1", "TEST1^DCM4CHE"); config.persist(device, null); HL7Application app = hl7Ext.findHL7Application("TEST1^DCM4CHE"); assertEquals(2...
IDWithIssuer { public static Set<IDWithIssuer> pidsOf(Attributes attrs) { IDWithIssuer pid = IDWithIssuer.pidOf(attrs); Sequence opidseq = attrs.getSequence(Tag.OtherPatientIDsSequence); if (opidseq == null) if (pid == null) return Collections.emptySet(); else return Collections.singleton(pid); Set<IDWithIssuer> pids =...
@Test public void pidsOfTest_faking_duplicate_by_using_same_PID_but_different_issuer() { Attributes rootWithMainId = createIdWithNS(NS); rootWithMainId.newSequence(OtherPatientIDsSequence, 0); Sequence other = rootWithMainId.getSequence(OtherPatientIDsSequence); Attributes otherPatientId = otherPatientIds("other_ns"); ...
IOD extends ArrayList<IOD.DataElement> { public static IOD load(String uri) throws IOException { if (uri.startsWith("resource:")) { try { uri = ResourceLocator.getResource(uri.substring(9), IOD.class); } catch (NullPointerException npe) { throw new FileNotFoundException(uri); } } else if (uri.indexOf(':') < 2) { uri = ...
@Test public void testValidateDICOMDIR() throws Exception { IOD iod = IOD.load("resource:dicomdir-iod.xml"); Attributes attrs = readDataset("DICOMDIR"); ValidationResult result = attrs.validate(iod); assertTrue(result.isValid()); } @Test public void testValidateCode() throws Exception { IOD iod = IOD.load("resource:cod...
PersonName { public String get(Component c) { return get(Group.Alphabetic, c); } PersonName(); PersonName(String s); PersonName(String s, boolean lenient); String toString(); String toString(Group g, boolean trim); String get(Component c); String get(Group g, Component c); void set(Component c, String s); void set(Gr...
@Test public void testValueOf() { PersonName pn = new PersonName( "Adams^John Robert Quincy^^Rev.^B.A. M.Div."); assertEquals("Adams", pn.get(PersonName.Component.FamilyName)); assertEquals("John Robert Quincy", pn.get(PersonName.Component.GivenName)); assertEquals("Rev.", pn.get(PersonName.Component.NamePrefix)); asse...
PersonName { public String toString() { int totLen = 0; Group lastGroup = Group.Alphabetic; for (Group g : Group.values()) { Component lastCompOfGroup = Component.FamilyName; for (Component c : Component.values()) { String s = get(g, c); if (s != null) { totLen += s.length(); lastGroup = g; lastCompOfGroup = c; } } tot...
@Test public void testToString() { PersonName pn = new PersonName(); pn.set(PersonName.Component.FamilyName, "Morrison-Jones"); pn.set(PersonName.Component.GivenName, "Susan"); pn.set(PersonName.Component.NameSuffix, "Ph.D., Chief Executive Officer"); assertEquals("Morrison-Jones^Susan^^^Ph.D., Chief Executive Officer"...
ValueSelector implements Serializable { @Override public String toString() { if (str == null) str = attributeSelector.toStringBuilder() .append("/Value[@number=\"") .append(valueIndex + 1) .append("\"]") .toString(); return str; } ValueSelector(int tag, String privateCreator, int index, ItemPointer... itemPointers); V...
@Test public void testToString() { ItemPointer ip = new ItemPointer(Tag.RequestAttributesSequence, 0); ValueSelector vs = new ValueSelector(Tag.StudyInstanceUID, null, 0, ip); assertEquals(XPATH, vs.toString()); }
LdapDicomConfiguration implements DicomConfiguration { @Override public synchronized boolean registerAETitle(String aet) throws ConfigurationException { ensureConfigurationExists(); try { registerAET(aet); return true; } catch (AETitleAlreadyExistsException e) { return false; } } LdapDicomConfiguration(); @SuppressWarn...
@Test public void testRegisterAETitle() throws Exception { config.unregisterAETitle("TEST-AET1"); assertTrue(config.registerAETitle("TEST-AET1")); assertFalse(config.registerAETitle("TEST-AET1")); assertTrue( Arrays.asList(config.listRegisteredAETitles()) .contains("TEST-AET1")); config.unregisterAETitle("TEST-AET1"); ...
ValueSelector implements Serializable { public static ValueSelector valueOf(String s) { int fromIndex = s.lastIndexOf("DicomAttribute"); try { return new ValueSelector(AttributeSelector.valueOf(s), AttributeSelector.selectNumber(s, fromIndex) - 1); } catch (Exception e) { throw new IllegalArgumentException(s); } } Valu...
@Test public void testValueOf() { ValueSelector vs = ValueSelector.valueOf(XPATH); assertEquals(Tag.StudyInstanceUID, vs.tag()); assertNull(vs.privateCreator()); assertEquals(0, vs.valueIndex()); assertEquals(1, vs.level()); ItemPointer ip = vs.itemPointer(0); assertEquals(Tag.RequestAttributesSequence, ip.sequenceTag)...
ElementDictionary { public static VR vrOf(int tag, String privateCreator) { return getElementDictionary(privateCreator).vrOf(tag); } protected ElementDictionary(String privateCreator, Class<?> tagClass); static ElementDictionary getStandardElementDictionary(); static ElementDictionary getElementDictionary(String priva...
@Test public void testVrOf() { for (int i = 0; i < TAGS.length; i++) assertEquals(VRS[i], ElementDictionary.vrOf(TAGS[i], null)); } @Test public void testPrivateVrOf() { for (int i = 0; i < SIEMENS_CSA_HEADER_TAGS.length; i++) assertEquals(SIEMENS_CSA_HEADER_VRS[i], ElementDictionary.vrOf(SIEMENS_CSA_HEADER_TAGS[i], SI...
ElementDictionary { public static String keywordOf(int tag, String privateCreator) { return getElementDictionary(privateCreator).keywordOf(tag); } protected ElementDictionary(String privateCreator, Class<?> tagClass); static ElementDictionary getStandardElementDictionary(); static ElementDictionary getElementDictionar...
@Test public void testKeywordOf() { for (int i = 0; i < TAGS.length; i++) assertEquals(KEYWORDS[i], ElementDictionary.keywordOf(TAGS[i], null)); } @Test public void testPrivateKeywordOf() { for (int i = 0; i < SIEMENS_CSA_HEADER_TAGS.length; i++) assertEquals(SIEMENS_CSA_HEADER_KEYWORDS[i], ElementDictionary.keywordOf(...
ElementDictionary { public static int tagForKeyword(String keyword, String privateCreatorID) { return getElementDictionary(privateCreatorID).tagForKeyword(keyword); } protected ElementDictionary(String privateCreator, Class<?> tagClass); static ElementDictionary getStandardElementDictionary(); static ElementDictionary...
@Test public void tagForKeyword() { for (int i = 0; i < KEYWORDS.length-1; i++) assertEquals(TAGS[i], ElementDictionary.tagForKeyword(KEYWORDS[i], null)); } @Test public void tagPrivateForKeyword() { for (int i = 0; i < SIEMENS_CSA_HEADER_KEYWORDS.length; i++) assertEquals(SIEMENS_CSA_HEADER_TAGS[i], ElementDictionary....
StringUtils { public static boolean matches(String s, String key, boolean matchNullOrEmpty, boolean ignoreCase) { if (key == null || key.isEmpty()) return true; if (s == null || s.isEmpty()) return matchNullOrEmpty; return containsWildCard(key) ? compilePattern(key, ignoreCase).matcher(s).matches() : ignoreCase ? key.e...
@Test public void testMatches() { assertTrue(StringUtils.matches("aBcD", "aBcD", false, false)); assertFalse(StringUtils.matches("aBcD", "abCd", false, false)); assertTrue(StringUtils.matches("aBcD", "abCd", false, true)); assertFalse(StringUtils.matches("aBcD", "ab*", false, false)); assertTrue(StringUtils.matches("aB...
AttributesFormat extends Format { @Override public StringBuffer format(Object obj, StringBuffer result, FieldPosition pos) { return format.format(toArgs((Attributes) obj), result, pos); } AttributesFormat(String pattern); static AttributesFormat valueOf(String s); @Override StringBuffer format(Object obj, StringBuffer ...
@Test public void testFormat() { Attributes attrs = new Attributes(); attrs.setString(Tag.ImageType, VR.CS, "ORIGINAL", "PRIMARY", "AXIAL"); attrs.setString(Tag.StudyDate, VR.DA, "20111012"); attrs.setString(Tag.StudyTime, VR.TM, "0930"); attrs.setString(Tag.StudyInstanceUID, VR.UI, "1.2.3"); attrs.setString(Tag.Series...
LdapDicomConfiguration implements DicomConfiguration { @Override public synchronized ConfigurationChanges persist(Device device, EnumSet<Option> options) throws ConfigurationException { ensureConfigurationExists(); String deviceName = device.getDeviceName(); String deviceDN = deviceRef(deviceName); boolean rollback = f...
@Test public void testPersist() throws Exception { try { config.removeDevice("Test-Device-1", null); } catch (ConfigurationNotFoundException e) {} Device device = createDevice("Test-Device-1", "TEST-AET1"); config.persist(device, null); ApplicationEntity ae = config.findApplicationEntity("TEST-AET1"); assertFalse(ae.is...
DateUtils { public static String formatDA(TimeZone tz, Date date) { return formatDA(tz, date, new StringBuilder(8)).toString(); } static String formatDA(TimeZone tz, Date date); static StringBuilder formatDA(TimeZone tz, Date date, StringBuilder toAppendTo); static String formatTM(TimeZone tz, Date date); ...
@Test public void testFormatDA() { assertEquals("19700101", DateUtils.formatDA(tz, new Date(0))); }
DateUtils { public static String formatTM(TimeZone tz, Date date) { return formatTM(tz, date, new DatePrecision()); } static String formatDA(TimeZone tz, Date date); static StringBuilder formatDA(TimeZone tz, Date date, StringBuilder toAppendTo); static String formatTM(TimeZone tz, Date date); static Strin...
@Test public void testFormatTM() { assertEquals("020000.000", DateUtils.formatTM(tz, new Date(0))); }
DateUtils { public static String formatDT(TimeZone tz, Date date) { return formatDT(tz, date, new DatePrecision()); } static String formatDA(TimeZone tz, Date date); static StringBuilder formatDA(TimeZone tz, Date date, StringBuilder toAppendTo); static String formatTM(TimeZone tz, Date date); static Strin...
@Test public void testFormatDT() { assertEquals("19700101020000.000", DateUtils.formatDT(tz, new Date(0))); } @Test public void testFormatDTwithTZ() { assertEquals("19700101020000.000+0200", DateUtils.formatDT(tz, new Date(0), new DatePrecision(Calendar.MILLISECOND, true))); }
DateUtils { public static Date parseDA(TimeZone tz, String s) { return parseDA(tz, s, false); } static String formatDA(TimeZone tz, Date date); static StringBuilder formatDA(TimeZone tz, Date date, StringBuilder toAppendTo); static String formatTM(TimeZone tz, Date date); static String formatTM(TimeZone tz...
@Test public void testParseDA() { assertEquals(-2 * HOUR, DateUtils.parseDA(tz, "19700101").getTime()); } @Test public void testParseDAacrnema() { assertEquals(-2 * HOUR, DateUtils.parseDA(tz, "1970.01.01").getTime()); } @Test public void testParseDAceil() { assertEquals(DAY - 2 * HOUR - 1, DateUtils.parseDA(tz, "19700...
DateUtils { public static Date parseTM(TimeZone tz, String s, DatePrecision precision) { return parseTM(tz, s, false, precision); } static String formatDA(TimeZone tz, Date date); static StringBuilder formatDA(TimeZone tz, Date date, StringBuilder toAppendTo); static String formatTM(TimeZone tz, Date date)...
@Test public void testParseTM() { DatePrecision precision = new DatePrecision(); assertEquals(0, DateUtils.parseTM(tz, "020000.000", precision).getTime()); assertEquals(Calendar.MILLISECOND, precision.lastField); } @Test public void testParseTMacrnema() { DatePrecision precision = new DatePrecision(); assertEquals(0, D...
LdapDicomConfiguration implements DicomConfiguration { @Override public ConfigurationChanges merge(Device device, EnumSet<Option> options) throws ConfigurationException { ConfigurationChanges diffs = configurationChangesOf(options); merge(device, options, diffs); return diffs; } LdapDicomConfiguration(); @SuppressWarni...
@Test public void testMerge() throws Exception { try { config.removeDevice("Test-Device-1", null); } catch (ConfigurationNotFoundException e) {} Device device = createDevice("Test-Device-1", "TEST-AET1"); config.persist(device, null); modifyDevice(device); config.merge(device, null); ApplicationEntity ae2 = config.find...
DateUtils { public static Date parseDT(TimeZone tz, String s, DatePrecision precision) { return parseDT(tz, s, false, precision); } static String formatDA(TimeZone tz, Date date); static StringBuilder formatDA(TimeZone tz, Date date, StringBuilder toAppendTo); static String formatTM(TimeZone tz, Date date)...
@Test public void testParseDT() { DatePrecision precision = new DatePrecision(); assertEquals(0, DateUtils.parseDT(tz, "19700101020000.000", precision).getTime()); assertEquals(Calendar.MILLISECOND, precision.lastField); assertFalse(precision.includeTimezone); } @Test public void testParseWithTZ() { DatePrecision preci...
IntHashMap implements Cloneable, java.io.Serializable { public int size() { return size; } IntHashMap(); IntHashMap(int expectedMaxSize); int size(); boolean isEmpty(); @SuppressWarnings("unchecked") V get(int key); boolean containsKey(int key); @SuppressWarnings("unchecked") V put(int key, V value); void trimToSize()...
@Test public void testSize() { assertEquals(15, map.size()); removeOdd(); assertEquals(7, map.size()); }
IntHashMap implements Cloneable, java.io.Serializable { @SuppressWarnings("unchecked") public V get(int key) { byte[] states = this.states; int[] keys = this.keys; int mask = keys.length - 1; int i = key & mask; while (states[i] != FREE) { if (keys[i] == key) return (V) values[i]; i = (i + 1) & mask; } return null; } I...
@Test public void testGet() { removeOdd(); testGet(map); }
IntHashMap implements Cloneable, java.io.Serializable { @SuppressWarnings("unchecked") public V put(int key, V value) { byte[] states = this.states; int[] keys = this.keys; int mask = keys.length - 1; int i = key & mask; while (states[i] > FREE) { if (keys[i] == key) { V oldValue = (V) values[i]; values[i] = value; ret...
@Test public void testPut() { removeOdd(); for (int i = 0; i < 45; i++) map.put(i, Integer.valueOf(i)); assertEquals(45, map.size()); for (int i = 0; i < 45; i++) assertEquals(Integer.valueOf(i), map.get(i)); }
IntHashMap implements Cloneable, java.io.Serializable { public boolean containsKey(int key) { byte[] states = this.states; int[] keys = this.keys; int mask = keys.length - 1; int i = key & mask; while (states[i] != FREE) { if (keys[i] == key) return states[i] > FREE; i = (i + 1) & mask; } return false; } IntHashMap(); ...
@Test public void testContainsKey() { removeOdd(); for (int i = 1; i < 45; i++) assertEquals((i & 1) == 0 && (i % 3) == 1, map.containsKey(i)); }
IntHashMap implements Cloneable, java.io.Serializable { public void rehash() { resize(keys.length); } IntHashMap(); IntHashMap(int expectedMaxSize); int size(); boolean isEmpty(); @SuppressWarnings("unchecked") V get(int key); boolean containsKey(int key); @SuppressWarnings("unchecked") V put(int key, V value); void t...
@Test public void testRehash() { removeOdd(); map.trimToSize(); testGet(map); }
JsonConfiguration { public void writeTo(DeviceInfo deviceInfo, JsonGenerator gen) { JsonWriter writer = new JsonWriter(gen); gen.writeStartObject(); gen.write("dicomDeviceName", deviceInfo.getDeviceName()); writer.writeNotNullOrDef("dicomDescription", deviceInfo.getDescription(), null); writer.writeNotNullOrDef("dicomM...
@Test public void testWriteTo() throws Exception { StringWriter writer = new StringWriter(); try ( JsonGenerator gen = Json.createGenerator(writer)) { JsonConfiguration config = new JsonConfiguration(); config.addJsonConfigurationExtension(new JsonAuditLoggerConfiguration()); config.addJsonConfigurationExtension(new Js...
IntHashMap implements Cloneable, java.io.Serializable { @SuppressWarnings("unchecked") public V remove(int key) { byte[] states = this.states; int[] keys = this.keys; int mask = keys.length - 1; int i = key & mask; while (states[i] != FREE) { if (keys[i] == key) { if (states[i] < FREE) return null; states[i] = REMOVED;...
@Test public void testRemove() { for (int i = 1; i < 45; i += 2) if ((i % 3) == 1) assertEquals(Integer.valueOf(i), map.remove(i)); else assertNull(map.remove(i)); }
IntHashMap implements Cloneable, java.io.Serializable { public void clear() { Arrays.fill(values, null); Arrays.fill(states, FREE); size = 0; free = keys.length >>> 1; } IntHashMap(); IntHashMap(int expectedMaxSize); int size(); boolean isEmpty(); @SuppressWarnings("unchecked") V get(int key); boolean containsKey(int ...
@Test public void testClear() { assertFalse(map.isEmpty()); map.clear(); assertTrue(map.isEmpty()); }
IntHashMap implements Cloneable, java.io.Serializable { @SuppressWarnings("unchecked") public Object clone() { try { IntHashMap<V> m = (IntHashMap<V>) super.clone(); m.states = states.clone(); m.keys = keys.clone(); m.values = values.clone(); return m; } catch (CloneNotSupportedException e) { throw new InternalError();...
@SuppressWarnings("unchecked") @Test public void testClone() { removeOdd(); IntHashMap<Integer> clone = (IntHashMap<Integer>) map.clone(); map.clear(); testGet(clone); }
ByteUtils { public static int bytesToUShortBE(byte[] bytes, int off) { return ((bytes[off] & 255) << 8) + (bytes[off + 1] & 255); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); static int bytesToUShor...
@Test public void testBytesToUShortBE() { assertEquals(-12345 & 0xffff, ByteUtils.bytesToUShortBE(SHORT_12345_BE, 0)); }
ByteUtils { public static int bytesToUShortLE(byte[] bytes, int off) { return ((bytes[off + 1] & 255) << 8) + (bytes[off] & 255); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); static int bytesToUShor...
@Test public void testBytesToUShortLE() { assertEquals(-12345 & 0xffff, ByteUtils.bytesToUShortLE(SHORT_12345_LE, 0)); }
ByteUtils { public static int bytesToShortBE(byte[] bytes, int off) { return (bytes[off] << 8) + (bytes[off + 1] & 255); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); static int bytesToUShortLE(byte[...
@Test public void testBytesToShortBE() { assertEquals(-12345, ByteUtils.bytesToShortBE(SHORT_12345_BE, 0)); }
ByteUtils { public static int bytesToShortLE(byte[] bytes, int off) { return (bytes[off + 1] << 8) + (bytes[off] & 255); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); static int bytesToUShortLE(byte[...
@Test public void testBytesToShortLE() { assertEquals(-12345, ByteUtils.bytesToShortLE(SHORT_12345_LE, 0)); }
ByteUtils { public static int bytesToIntBE(byte[] bytes, int off) { return (bytes[off] << 24) + ((bytes[off + 1] & 255) << 16) + ((bytes[off + 2] & 255) << 8) + (bytes[off + 3] & 255); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToU...
@Test public void testBytesToIntBE() { assertEquals(-12345, ByteUtils.bytesToIntBE(INT_12345_BE, 0)); }
ByteUtils { public static int bytesToIntLE(byte[] bytes, int off) { return (bytes[off + 3] << 24) + ((bytes[off + 2] & 255) << 16) + ((bytes[off + 1] & 255) << 8) + (bytes[off] & 255); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToU...
@Test public void testBytesToIntLE() { assertEquals(-12345, ByteUtils.bytesToIntLE(INT_12345_LE, 0)); }
ByteUtils { public static int bytesToTagBE(byte[] bytes, int off) { return bytesToIntBE(bytes, off); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); static int bytesToUShortLE(byte[] bytes, int off); s...
@Test public void testBytesToTagBE() { assertEquals(Tag.PixelData, ByteUtils.bytesToTagBE(TAG_PIXEL_DATA_BE, 0)); }
AttributeSelector implements Serializable { @Override public String toString() { if (str == null) str = toStringBuilder().toString(); return str; } AttributeSelector(int tag); AttributeSelector(int tag, String privateCreator); AttributeSelector(int tag, String privateCreator, ItemPointer... itemPointers); AttributeS...
@Test public void testToString() { ItemPointer ip = new ItemPointer(Tag.RequestAttributesSequence); AttributeSelector selector = new AttributeSelector(Tag.StudyInstanceUID, null, ip); assertEquals(XPATH, selector.toString()); }
ByteUtils { public static int bytesToTagLE(byte[] bytes, int off) { return (bytes[off + 1] << 24) + ((bytes[off] & 255) << 16) + ((bytes[off + 3] & 255) << 8) + (bytes[off + 2] & 255); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToU...
@Test public void testBytesToTagLE() { assertEquals(Tag.PixelData, ByteUtils.bytesToTagLE(TAG_PIXEL_DATA_LE, 0)); }
ByteUtils { public static float bytesToFloatBE(byte[] bytes, int off) { return Float.intBitsToFloat(bytesToIntBE(bytes, off)); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); static int bytesToUShortLE...
@Test public void testBytesToFloatBE() { assertEquals((float) Math.PI, ByteUtils.bytesToFloatBE(FLOAT_PI_BE, 0), 0); }
ByteUtils { public static float bytesToFloatLE(byte[] bytes, int off) { return Float.intBitsToFloat(bytesToIntLE(bytes, off)); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); static int bytesToUShortLE...
@Test public void testBytesToFloatLE() { assertEquals((float) Math.PI, ByteUtils.bytesToFloatLE(FLOAT_PI_LE, 0), 0); }
ByteUtils { public static double bytesToDoubleBE(byte[] bytes, int off) { return Double.longBitsToDouble(bytesToLongBE(bytes, off)); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); static int bytesToUS...
@Test public void testBytesToDoubleBE() { assertEquals(Math.PI, ByteUtils.bytesToDoubleBE(DOUBLE_PI_BE, 0), 0); }
ByteUtils { public static double bytesToDoubleLE(byte[] bytes, int off) { return Double.longBitsToDouble(bytesToLongLE(bytes, off)); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); static int bytesToUS...
@Test public void testBytesToDoubleLE() { assertEquals(Math.PI, ByteUtils.bytesToDoubleLE(DOUBLE_PI_LE, 0), 0); }
ByteUtils { public static byte[] shortToBytesBE(int i, byte[] bytes, int off) { bytes[off] = (byte) (i >> 8); bytes[off + 1] = (byte) i; return bytes; } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); st...
@Test public void testShortToBytesBE() { assertArrayEquals(SHORT_12345_BE, ByteUtils.shortToBytesBE(-12345, new byte[2] , 0)); }
ByteUtils { public static byte[] shortToBytesLE(int i, byte[] bytes, int off) { bytes[off + 1] = (byte) (i >> 8); bytes[off] = (byte) i; return bytes; } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); st...
@Test public void testShortToBytesLE() { assertArrayEquals(SHORT_12345_LE, ByteUtils.shortToBytesLE(-12345, new byte[2] , 0)); }
ByteUtils { public static byte[] intToBytesBE(int i, byte[] bytes, int off) { bytes[off] = (byte) (i >> 24); bytes[off + 1] = (byte) (i >> 16); bytes[off + 2] = (byte) (i >> 8); bytes[off + 3] = (byte) i; return bytes; } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boole...
@Test public void testIntToBytesBE() { assertArrayEquals(INT_12345_BE, ByteUtils.intToBytesBE(-12345, new byte[4] , 0)); }
ByteUtils { public static byte[] intToBytesLE(int i, byte[] bytes, int off) { bytes[off + 3] = (byte) (i >> 24); bytes[off + 2] = (byte) (i >> 16); bytes[off + 1] = (byte) (i >> 8); bytes[off] = (byte) i; return bytes; } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boole...
@Test public void testIntToBytesLE() { assertArrayEquals(INT_12345_LE, ByteUtils.intToBytesLE(-12345, new byte[4] , 0)); }
ByteUtils { public static byte[] tagToBytesBE(int i, byte[] bytes, int off) { return intToBytesBE(i, bytes, off); } static int bytesToVR(byte[] bytes, int off); static int bytesToUShort(byte[] bytes, int off, boolean bigEndian); static int bytesToUShortBE(byte[] bytes, int off); static int bytesToUShortLE(byte[] bytes...
@Test public void testTagToBytesBE() { assertArrayEquals(TAG_PIXEL_DATA_BE, ByteUtils.tagToBytesBE(Tag.PixelData, new byte[4] , 0)); }
AttributeSelector implements Serializable { public static AttributeSelector valueOf(String s) { int fromIndex = s.lastIndexOf("DicomAttribute"); try { return new AttributeSelector( selectTag(s, fromIndex), selectPrivateCreator(s, fromIndex), itemPointersOf(s, fromIndex)); } catch (Exception e) { throw new IllegalArgume...
@Test public void testValueOf() { AttributeSelector selector = AttributeSelector.valueOf(XPATH); assertEquals(Tag.StudyInstanceUID, selector.tag()); assertNull(selector.privateCreator()); assertEquals(1, selector.level()); ItemPointer ip = selector.itemPointer(0); assertEquals(Tag.RequestAttributesSequence, ip.sequence...
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); ...
@Test public void testStartUpProdServletContext() throws ServletException { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); webConfigurer.onStartup(servletContext); assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry); assertThat(servletContext.get...
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("html", "text/html;charset=utf-8"); mappings.add("json", "text/html;char...
@Test public void testCustomizeServletContainer() { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory(); webConfigurer.customize(container); assertThat(container.getMimeMappings().get("abs")).isEqualTo("aud...
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Bean public CorsFilter corsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = jHipsterProperties.getCors(); if (config.getAllowedOrigins() != null && !config.getAl...
@Test public void testCorsFilterOnApiPath() throws Exception { props.getCors().setAllowedOrigins(Collections.singletonList("*")); props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE")); props.getCors().setAllowedHeaders(Collections.singletonList("*")); props.getCors().setMaxAge(1800L); props.g...
WebConfigurer implements ServletContextInitializer, EmbeddedServletContainerCustomizer { @Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); ...
@Test public void testStartUpProdServletContext() throws ServletException { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); webConfigurer.onStartup(servletContext); assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry); assertThat(servletContext.get...
Post extends AuditableEntity { @PrePersist public void slugify(){ this.slug = new Slugify().slugify(this.title); } @PrePersist void slugify(); }
@Test public void testSlug() { System.out.println("getSlug"); Post instance = new Post(); instance.setTitle("test post 1"); instance.slugify(); assertEquals("test-post-1", instance.getSlug()); }
PostService { public Post createPost(PostForm form) { Post _post = Post.builder() .title(form.getTitle()) .content(form.getContent()) .build(); Post saved = this.postRepository.save(_post); return saved; } Post createPost(PostForm form); Post updatePost(String slug, PostForm form); void deletePost(String slug); }
@Test public void createPost() { final String TITLE = "test post title"; final String CONTENT = "test post content"; final PostForm input = PostForm.builder().title(TITLE).content(CONTENT).build(); Post expected = Post.builder().title(TITLE).content(CONTENT).build(); expected.setId(1L); given(posts.save(Post.builder()....
UserServiceClient { public User findByUsername(String username) { try { ResponseEntity<User> response = this.restTemplate.getForEntity(userServiceUrl + "/users/{username}", User.class, username); return response.getBody(); } catch (HttpClientErrorException e) { if (e.getStatusCode() == NOT_FOUND) { return null; } } ret...
@Test public void testFindbyUsername() { this.server.expect(requestTo(userServiceUrl + "/users/user")) .andRespond(withSuccess(new ClassPathResource("/find-user-by-username.json"), MediaType.APPLICATION_JSON_UTF8)); User user = this.client.findByUsername("user"); assertNotNull(user); assertEquals("user", user.getUserna...
GraphExporter { public BufferedImage exportCurrentGraph(mxGraph graph, double scale, UIAbstractBlock selectedBlock, BlockState<? extends LatticeElement> state) { BufferedImage graphImage; int stateImageWidth = (int) (STATE_AREA_WIDTH * scale); BufferedImage stateImage = null; if (selectedBlock != null && state != null)...
@Test public void shouldCreateSmallExportImage() throws IOException { BufferedImage exportedImage = graphExporter.exportCurrentGraph(graph, 1.0, null, null); BufferedImage referenceImage = ImageIO.read(getClass().getResourceAsStream("/export-small.png")); Assert.assertEquals("", TestUtils.bufferedImagesEqual(exportedIm...
GraphExporter { public void batchExportAsync(DFAExecution<? extends LatticeElement> dfa, double scale, boolean includeLineSteps, GraphExportCallback callback) { dfa = dfa.clone(); VisualGraphPanel panel = new VisualGraphPanel(); panel.setJumpToAction(true); GraphUIController controller = new GraphUIController(panel); c...
@Test public void shouldPerformBatchExport() throws InterruptedException { String code = "public class shouldPerformBatchExportClass { int test(int a) { " + " if (a < 10) { " + " a = 20; " + " } " + " return a*2; " + " } }"; CodeProcessor codeProcessor = new CodeProcessor(code); GraphBuilder builder = new GraphBuilder(...
GraphUIController { public void refresh() { if (dfa == null) { throw new IllegalStateException("Graph has not been built using start() yet."); } panel.renderGraph(dfa); if (!panel.isJumpToActionEnabled()) { updateStatePanel(); } } GraphUIController(VisualGraphPanel panel); void start(final DFAExecution<? extends Lattic...
@Test(expected = IllegalStateException.class) public void refreshShouldNotBePossibleBeforeStart() { controller.refresh(); }
GraphUIController { public void start(final DFAExecution<? extends LatticeElement> dfa) { if (this.dfa != null) { throw new IllegalStateException("Visual graph was already built."); } this.dfa = dfa; ControlFlowGraph dfaGraph = dfa.getCFG(); List<BasicBlock> dfaBasicBlocks = dfaGraph.getBasicBlocks(); Map<BasicBlock, U...
@Test(expected = IllegalStateException.class) public void startShouldNotBePossibleTwice() { CodeProcessor codeProcessor = new CodeProcessor("void emptyInside() {}"); GraphBuilder builder = new GraphBuilder(codeProcessor.getPath(), codeProcessor.getClassName()); SimpleBlockGraph blockGraph = builder.buildGraph("void emp...
Tracing extends org.apache.cassandra.tracing.Tracing { Span spanFromPayload(Tracer tracer, @Nullable Map<String, ByteBuffer> payload) { ByteBuffer b3 = payload != null ? payload.get("b3") : null; if (b3 == null) return tracer.nextSpan(); TraceContextOrSamplingFlags extracted = B3SingleFormat.parseB3SingleFormat(UTF_8.d...
@Test public void spanFromPayload_startsTraceOnNullPayload() { assertThat(cassandraTracing.spanFromPayload(tracing.tracer(), null)) .isNotNull(); } @Test public void spanFromPayload_startsTraceOnAbsentB3SingleEntry() { assertThat(cassandraTracing.spanFromPayload(tracing.tracer(), Collections.emptyMap())) .isNotNull(); ...
HashTableHipsterDirectedGraph extends HashTableHipsterGraph<V,E> implements HipsterDirectedGraph<V,E> { @Override public GraphEdge<V,E> connect(V v1, V v2, E value){ Preconditions.checkArgument(v1 != null && v2 != null, "Vertices cannot be null"); GraphEdge<V,E> edge = new DirectedEdge<V, E>(v1, v2, value); graphTable....
@Test public void testConnect() throws Exception { directedGraph.connect("F", "G", 1d); assertEquals("F", directedGraph.incomingEdgesOf("G").iterator().next().getVertex1()); }
HashBasedHipsterGraph implements HipsterMutableGraph<V,E> { @Override public boolean add(V v){ if(!connected.containsKey(v)){ connected.put(v, new LinkedHashSet<GraphEdge<V, E>>()); return true; } return false; } HashBasedHipsterGraph(); @Override boolean add(V v); @Override Set<V> add(V... vertices); @Override boolean...
@Test public void testEdgesWithDisconnectedVertices() throws Exception { graph.add("X"); graph.add("Y"); testGraphEdges(); } @Test public void testAdd() throws Exception { graph.add("X"); Set vertices = Sets.newHashSet(graph.vertices()); assertTrue(vertices.contains("X")); assertTrue(vertices.size()==size+1); }
HashBasedHipsterGraph implements HipsterMutableGraph<V,E> { @Override public boolean remove(V v){ Set<GraphEdge<V, E>> edges = this.connected.get(v); if (edges == null) return false; for(Iterator<GraphEdge<V,E>> it = edges.iterator(); it.hasNext(); ){ GraphEdge<V,E> edge = it.next(); it.remove(); V v2 = edge.getVertex1...
@Test public void testRemove() throws Exception { graph.remove("v1"); assertFalse(Sets.newHashSet(graph.vertices()).contains("v1")); }
HashBasedHipsterGraph implements HipsterMutableGraph<V,E> { @Override public GraphEdge<V,E> connect(V v1, V v2, E value){ if(v1 == null || v2 == null) throw new IllegalArgumentException("Invalid vertices. A vertex cannot be null"); if (!connected.containsKey(v1)) throw new IllegalArgumentException(v1 + " is not a verte...
@Test public void testConnect() throws Exception { graph.add("X"); graph.add("Y"); graph.connect("X","Y",1.0d); assertTrue(Sets.newHashSet(graph.vertices()).contains("X")); assertTrue(Sets.newHashSet(graph.vertices()).contains("Y")); }
HashBasedHipsterGraph implements HipsterMutableGraph<V,E> { @Override public Iterable<V> vertices() { return connected.keySet(); } HashBasedHipsterGraph(); @Override boolean add(V v); @Override Set<V> add(V... vertices); @Override boolean remove(V v); @Override Set<V> remove(V... vertices); @Override GraphEdge<V,E> con...
@Test public void testVertices() throws Exception { Set vertices = Sets.newHashSet(graph.vertices()); assertEquals(size, vertices.size()); }
HashBasedHipsterGraph implements HipsterMutableGraph<V,E> { @Override public Iterable<GraphEdge<V, E>> edgesOf(V vertex) { Set<GraphEdge<V, E>> set = connected.get(vertex); if (set == null) set = Collections.emptySet(); return set; } HashBasedHipsterGraph(); @Override boolean add(V v); @Override Set<V> add(V... vertice...
@Test public void testEdgesOf() throws Exception { Set edges = Sets.newHashSet(graph.edgesOf("v1")); assertEquals(size-1, edges.size()); }
HashBasedHipsterDirectedGraph extends HashBasedHipsterGraph<V, E> implements HipsterMutableGraph<V, E>, HipsterDirectedGraph<V, E> { @Override public Iterable<GraphEdge<V, E>> outgoingEdgesOf(final V vertex) { return F.filter(edgesOf(vertex), new Function<GraphEdge<V, E>, Boolean>() { @Override public Boolean apply(Gra...
@Test public void testOutgoingEdgesOf() throws Exception { for(int i=0; i<size; i++) { Set edges = Sets.newHashSet(graph.outgoingEdgesOf("v"+i)); assertEquals(size-(i+1), edges.size()); } }
HashBasedHipsterDirectedGraph extends HashBasedHipsterGraph<V, E> implements HipsterMutableGraph<V, E>, HipsterDirectedGraph<V, E> { @Override public Iterable<GraphEdge<V, E>> incomingEdgesOf(final V vertex) { return F.filter(edgesOf(vertex), new Function<GraphEdge<V, E>, Boolean>() { @Override public Boolean apply(Gra...
@Test public void testIncomingEdgesOf() throws Exception { for(int i=0; i<size; i++) { Set edges = Sets.newHashSet(graph.incomingEdgesOf("v"+i)); assertEquals(i, edges.size()); } }
HashBasedHipsterDirectedGraph extends HashBasedHipsterGraph<V, E> implements HipsterMutableGraph<V, E>, HipsterDirectedGraph<V, E> { @Override public Iterable<GraphEdge<V, E>> edges() { return F.map( F.filter(HashBasedHipsterDirectedGraph.super.vedges(), new Function<Map.Entry<V, GraphEdge<V, E>>, Boolean>() { @Overrid...
@Test public void testEdges() throws Exception { Set edges = Sets.newHashSet(graph.edges()); assertEquals(size*(size-1)/2, edges.size()); }
HashTableHipsterDirectedGraph extends HashTableHipsterGraph<V,E> implements HipsterDirectedGraph<V,E> { @Override public Iterable<GraphEdge<V, E>> outgoingEdgesOf(V vertex) { return graphTable.row(vertex).values(); } @Override GraphEdge<V,E> connect(V v1, V v2, E value); @Override Iterable<GraphEdge<V, E>> outgoingEdg...
@Test public void testOutgoingEdgesOf() throws Exception { Set<DirectedEdge<String, Double>> expected = new HashSet<DirectedEdge<String, Double>>(); expected.add(new DirectedEdge<String, Double>("B", "C", 5d)); expected.add(new DirectedEdge<String, Double>("B", "D", 10d)); assertEquals(expected, Sets.newHashSet(directe...
HashTableHipsterDirectedGraph extends HashTableHipsterGraph<V,E> implements HipsterDirectedGraph<V,E> { @Override public Iterable<GraphEdge<V, E>> incomingEdgesOf(V vertex) { return graphTable.column(vertex).values(); } @Override GraphEdge<V,E> connect(V v1, V v2, E value); @Override Iterable<GraphEdge<V, E>> outgoing...
@Test public void testIncomingEdgesOf() throws Exception { Set<DirectedEdge<String, Double>> expected = new HashSet<DirectedEdge<String, Double>>(); expected.add(new DirectedEdge<String, Double>("B", "C", 5d)); expected.add(new DirectedEdge<String, Double>("A", "C", 2d)); assertEquals(expected, Sets.newHashSet(directed...
HashTableHipsterGraph implements HipsterGraph<V,E> { public void add(V v){ if (!graphTable.containsColumn(v) && !graphTable.containsRow(v)){ disconnected.add(v); } } void add(V v); void remove(V v); void remove(V v, GraphEdge<V,E> edge); GraphEdge<V,E> connect(V v1, V v2, E value); @Override Iterable<GraphEdge<V, E>> ...
@Test public void testAdd() throws Exception { graph.add("G"); assertTrue(Sets.newHashSet(graph.vertices()).contains("G")); }
HashTableHipsterGraph implements HipsterGraph<V,E> { public void remove(V v){ for(GraphEdge<V,E> edge : edgesOf(v)){ V connectedVertex = edge.getVertex1().equals(v) ? edge.getVertex2() : edge.getVertex1(); if (!greaterThan(1, edgesOf(connectedVertex))){ disconnected.add(connectedVertex); } } if (graphTable.containsRow(...
@Test public void testRemove() throws Exception { graph.remove("B"); assertFalse(Sets.newHashSet(graph.vertices()).contains("B")); }
HashTableHipsterGraph implements HipsterGraph<V,E> { public GraphEdge<V,E> connect(V v1, V v2, E value){ Preconditions.checkArgument(v1 != null && v2 != null, "Vertices cannot be null"); GraphEdge<V,E> edge = new UndirectedEdge<V, E>(v1, v2, value); graphTable.put(v1, v2, edge); graphTable.put(v2, v1, edge); disconnect...
@Test public void testConnect() throws Exception { graph.connect("X","Y",1.0d); assertTrue(Sets.newHashSet(graph.vertices()).contains("X")); assertTrue(Sets.newHashSet(graph.vertices()).contains("Y")); }
HashTableHipsterGraph implements HipsterGraph<V,E> { @Override public Iterable<GraphEdge<V, E>> edges() { return graphTable.values(); } void add(V v); void remove(V v); void remove(V v, GraphEdge<V,E> edge); GraphEdge<V,E> connect(V v1, V v2, E value); @Override Iterable<GraphEdge<V, E>> edges(); @Override Iterable<V>...
@Test public void testEdges() throws Exception { Set<GraphEdge<String,Double>> expected = new HashSet<GraphEdge<String, Double>>(); expected.add(new UndirectedEdge<String, Double>("A","B",4d)); expected.add(new UndirectedEdge<String, Double>("A","C",2d)); expected.add(new UndirectedEdge<String, Double>("B","C",5d)); ex...
HashTableHipsterGraph implements HipsterGraph<V,E> { @Override public Iterable<V> vertices() { return Sets.union(Sets.union(graphTable.rowKeySet(), graphTable.columnKeySet()), disconnected); } void add(V v); void remove(V v); void remove(V v, GraphEdge<V,E> edge); GraphEdge<V,E> connect(V v1, V v2, E value); @Override...
@Test public void testVertices() throws Exception { Set<String> expected = Sets.newHashSet("A","B","C","D","E","F"); assertEquals(expected, graph.vertices()); }
HashTableHipsterGraph implements HipsterGraph<V,E> { @Override public Iterable<GraphEdge<V, E>> edgesOf(V vertex) { return Sets.union(Sets.newHashSet(graphTable.row(vertex).values()), Sets.newHashSet(graphTable.column(vertex).values())); } void add(V v); void remove(V v); void remove(V v, GraphEdge<V,E> edge); GraphEd...
@Test public void testEdgesOf() throws Exception { Set<GraphEdge<String,Double>> expected = new HashSet<GraphEdge<String, Double>>(); expected.add(new UndirectedEdge<String, Double>("B","D",10d)); expected.add(new UndirectedEdge<String, Double>("A","B",4d)); expected.add(new UndirectedEdge<String, Double>("B","C",5d));...
HashBasedHipsterGraph implements HipsterMutableGraph<V,E> { @Override public Iterable<GraphEdge<V, E>> edges() { return F.map(vedges(), new Function<Map.Entry<V, GraphEdge<V, E>>, GraphEdge<V, E>>() { @Override public GraphEdge<V, E> apply(Map.Entry<V, GraphEdge<V, E>> entry) { return entry.getValue(); } }); } HashBase...
@Test public void testEdges() throws Exception { testGraphEdges(); }
CallArgumentsToByteArray { public byte[] getGasPrice() { byte[] gasPrice = new byte[] {0}; if (args.gasPrice != null && args.gasPrice.length() != 0) { gasPrice = stringHexToByteArray(args.gasPrice); } return gasPrice; } CallArgumentsToByteArray(Web3.CallArguments args); byte[] getGasPrice(); byte[] getGasLimit(); byte[...
@Test public void getGasPriceWhenValueIsNull() throws Exception { Web3.CallArguments args = new Web3.CallArguments(); CallArgumentsToByteArray byteArrayArgs = new CallArgumentsToByteArray(args); Assert.assertArrayEquals(new byte[] {0}, byteArrayArgs.getGasPrice()); } @Test public void getGasPriceWhenValueIsEmpty() thro...