target stringlengths 20 113k | src_fm stringlengths 11 86.3k | src_fm_fc stringlengths 21 86.4k | src_fm_fc_co stringlengths 30 86.4k | src_fm_fc_ms stringlengths 42 86.8k | src_fm_fc_ms_ff stringlengths 43 86.8k |
|---|---|---|---|---|---|
@Test public void rememberLastBlockSeenHash() throws Exception { BigInteger v1 = toNanoCoins(5, 0); BigInteger v2 = toNanoCoins(0, 50); BigInteger v3 = toNanoCoins(0, 25); Transaction t1 = createFakeTx(params, v1, myAddress); Transaction t2 = createFakeTx(params, v2, myAddress); Transaction t3 = createFakeTx(params, v3... | public Sha256Hash getLastBlockSeenHash() { lock.lock(); try { return lastBlockSeenHash; } finally { lock.unlock(); } } | Wallet implements Serializable, BlockChainListener { public Sha256Hash getLastBlockSeenHash() { lock.lock(); try { return lastBlockSeenHash; } finally { lock.unlock(); } } } | Wallet implements Serializable, BlockChainListener { public Sha256Hash getLastBlockSeenHash() { lock.lock(); try { return lastBlockSeenHash; } finally { lock.unlock(); } } Wallet(NetworkParameters params); Wallet(NetworkParameters params, KeyCrypter keyCrypter); } | Wallet implements Serializable, BlockChainListener { public Sha256Hash getLastBlockSeenHash() { lock.lock(); try { return lastBlockSeenHash; } finally { lock.unlock(); } } Wallet(NetworkParameters params); Wallet(NetworkParameters params, KeyCrypter keyCrypter); NetworkParameters getNetworkParameters(); Iterable<ECKey... | Wallet implements Serializable, BlockChainListener { public Sha256Hash getLastBlockSeenHash() { lock.lock(); try { return lastBlockSeenHash; } finally { lock.unlock(); } } Wallet(NetworkParameters params); Wallet(NetworkParameters params, KeyCrypter keyCrypter); NetworkParameters getNetworkParameters(); Iterable<ECKey... |
@Test public void getPeer_all() throws Exception{ SeedPeers seedPeers = new SeedPeers(NetworkParameters.prodNet()); for(int i = 0; i < SeedPeers.seedAddrs.length; ++i){ assertThat("Failed on index: "+i, seedPeers.getPeer(), notNullValue()); } assertThat(seedPeers.getPeer(), equalTo(null)); } | public InetSocketAddress getPeer() throws PeerDiscoveryException { try { return nextPeer(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } | SeedPeers implements PeerDiscovery { public InetSocketAddress getPeer() throws PeerDiscoveryException { try { return nextPeer(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } } | SeedPeers implements PeerDiscovery { public InetSocketAddress getPeer() throws PeerDiscoveryException { try { return nextPeer(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } SeedPeers(NetworkParameters params); } | SeedPeers implements PeerDiscovery { public InetSocketAddress getPeer() throws PeerDiscoveryException { try { return nextPeer(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } SeedPeers(NetworkParameters params); InetSocketAddress getPeer(); InetSocketAddress[] getPeers(long timeoutValue, T... | SeedPeers implements PeerDiscovery { public InetSocketAddress getPeer() throws PeerDiscoveryException { try { return nextPeer(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } SeedPeers(NetworkParameters params); InetSocketAddress getPeer(); InetSocketAddress[] getPeers(long timeoutValue, T... |
@Test public void respectMaxStandardSize() throws Exception { sendMoneyToWallet(Utils.toNanoCoins(100, 0), AbstractBlockChain.NewBlockType.BEST_CHAIN); Transaction tx = new Transaction(params); byte[] bits = new byte[20]; new Random().nextBytes(bits); BigInteger v = Utils.toNanoCoins(0, 1); for (int i = 0; i < 3100; i+... | public boolean completeTx(SendRequest req) { lock.lock(); try { Preconditions.checkArgument(!req.completed, "Given SendRequest has already been completed."); BigInteger value = BigInteger.ZERO; for (TransactionOutput output : req.tx.getOutputs()) { value = value.add(output.getValue()); } value = value.add(req.fee); log... | Wallet implements Serializable, BlockChainListener { public boolean completeTx(SendRequest req) { lock.lock(); try { Preconditions.checkArgument(!req.completed, "Given SendRequest has already been completed."); BigInteger value = BigInteger.ZERO; for (TransactionOutput output : req.tx.getOutputs()) { value = value.add(... | Wallet implements Serializable, BlockChainListener { public boolean completeTx(SendRequest req) { lock.lock(); try { Preconditions.checkArgument(!req.completed, "Given SendRequest has already been completed."); BigInteger value = BigInteger.ZERO; for (TransactionOutput output : req.tx.getOutputs()) { value = value.add(... | Wallet implements Serializable, BlockChainListener { public boolean completeTx(SendRequest req) { lock.lock(); try { Preconditions.checkArgument(!req.completed, "Given SendRequest has already been completed."); BigInteger value = BigInteger.ZERO; for (TransactionOutput output : req.tx.getOutputs()) { value = value.add(... | Wallet implements Serializable, BlockChainListener { public boolean completeTx(SendRequest req) { lock.lock(); try { Preconditions.checkArgument(!req.completed, "Given SendRequest has already been completed."); BigInteger value = BigInteger.ZERO; for (TransactionOutput output : req.tx.getOutputs()) { value = value.add(... |
@Test public void testIp() throws Exception { byte[] bytes = Hex.decode("41043e96222332ea7848323c08116dddafbfa917b8e37f0bdf63841628267148588a09a43540942d58d49717ad3fabfe14978cf4f0a8b84d2435dad16e9aa4d7f935ac"); Script s = new Script(params, bytes, 0, bytes.length); assertTrue(s.isSentToRawPubKey()); } | public boolean isSentToRawPubKey() { if (chunks.size() != 2) return false; return chunks.get(1).equalsOpCode(OP_CHECKSIG) && !chunks.get(0).isOpCode && chunks.get(0).data.length > 1; } | Script { public boolean isSentToRawPubKey() { if (chunks.size() != 2) return false; return chunks.get(1).equalsOpCode(OP_CHECKSIG) && !chunks.get(0).isOpCode && chunks.get(0).data.length > 1; } } | Script { public boolean isSentToRawPubKey() { if (chunks.size() != 2) return false; return chunks.get(1).equalsOpCode(OP_CHECKSIG) && !chunks.get(0).isOpCode && chunks.get(0).data.length > 1; } private Script(); Script(NetworkParameters params, byte[] programBytes, int offset, int length); } | Script { public boolean isSentToRawPubKey() { if (chunks.size() != 2) return false; return chunks.get(1).equalsOpCode(OP_CHECKSIG) && !chunks.get(0).isOpCode && chunks.get(0).data.length > 1; } private Script(); Script(NetworkParameters params, byte[] programBytes, int offset, int length); String toString(); static S... | Script { public boolean isSentToRawPubKey() { if (chunks.size() != 2) return false; return chunks.get(1).equalsOpCode(OP_CHECKSIG) && !chunks.get(0).isOpCode && chunks.get(0).data.length > 1; } private Script(); Script(NetworkParameters params, byte[] programBytes, int offset, int length); String toString(); static S... |
@Test public void dataDrivenValidScripts() throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader( getClass().getResourceAsStream("script_valid.json"), Charset.forName("UTF-8"))); NetworkParameters params = NetworkParameters.testNet(); String script = ""; while (in.ready()) { String line = in.r... | public void correctlySpends(Transaction txContainingThis, long scriptSigIndex, Script scriptPubKey, boolean enforceP2SH) throws ScriptException { if (program.length > 10000 || scriptPubKey.program.length > 10000) throw new ScriptException("Script larger than 10,000 bytes"); LinkedList<byte[]> stack = new LinkedList<byt... | Script { public void correctlySpends(Transaction txContainingThis, long scriptSigIndex, Script scriptPubKey, boolean enforceP2SH) throws ScriptException { if (program.length > 10000 || scriptPubKey.program.length > 10000) throw new ScriptException("Script larger than 10,000 bytes"); LinkedList<byte[]> stack = new Linke... | Script { public void correctlySpends(Transaction txContainingThis, long scriptSigIndex, Script scriptPubKey, boolean enforceP2SH) throws ScriptException { if (program.length > 10000 || scriptPubKey.program.length > 10000) throw new ScriptException("Script larger than 10,000 bytes"); LinkedList<byte[]> stack = new Linke... | Script { public void correctlySpends(Transaction txContainingThis, long scriptSigIndex, Script scriptPubKey, boolean enforceP2SH) throws ScriptException { if (program.length > 10000 || scriptPubKey.program.length > 10000) throw new ScriptException("Script larger than 10,000 bytes"); LinkedList<byte[]> stack = new Linke... | Script { public void correctlySpends(Transaction txContainingThis, long scriptSigIndex, Script scriptPubKey, boolean enforceP2SH) throws ScriptException { if (program.length > 10000 || scriptPubKey.program.length > 10000) throw new ScriptException("Script larger than 10,000 bytes"); LinkedList<byte[]> stack = new Linke... |
@Test public void dataDrivenInvalidScripts() throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader( getClass().getResourceAsStream("script_invalid.json"), Charset.forName("UTF-8"))); NetworkParameters params = NetworkParameters.testNet(); String script = ""; while (in.ready()) { String line = ... | public void correctlySpends(Transaction txContainingThis, long scriptSigIndex, Script scriptPubKey, boolean enforceP2SH) throws ScriptException { if (program.length > 10000 || scriptPubKey.program.length > 10000) throw new ScriptException("Script larger than 10,000 bytes"); LinkedList<byte[]> stack = new LinkedList<byt... | Script { public void correctlySpends(Transaction txContainingThis, long scriptSigIndex, Script scriptPubKey, boolean enforceP2SH) throws ScriptException { if (program.length > 10000 || scriptPubKey.program.length > 10000) throw new ScriptException("Script larger than 10,000 bytes"); LinkedList<byte[]> stack = new Linke... | Script { public void correctlySpends(Transaction txContainingThis, long scriptSigIndex, Script scriptPubKey, boolean enforceP2SH) throws ScriptException { if (program.length > 10000 || scriptPubKey.program.length > 10000) throw new ScriptException("Script larger than 10,000 bytes"); LinkedList<byte[]> stack = new Linke... | Script { public void correctlySpends(Transaction txContainingThis, long scriptSigIndex, Script scriptPubKey, boolean enforceP2SH) throws ScriptException { if (program.length > 10000 || scriptPubKey.program.length > 10000) throw new ScriptException("Script larger than 10,000 bytes"); LinkedList<byte[]> stack = new Linke... | Script { public void correctlySpends(Transaction txContainingThis, long scriptSigIndex, Script scriptPubKey, boolean enforceP2SH) throws ScriptException { if (program.length > 10000 || scriptPubKey.program.length > 10000) throw new ScriptException("Script larger than 10,000 bytes"); LinkedList<byte[]> stack = new Linke... |
@Test public void decoding() throws Exception { Address a = new Address(testParams, "n4eA2nbYqErp7H6jebchxAN59DmNpksexv"); assertEquals("fda79a24e50ff70ff42f7d89585da5bd19d9e5cc", Utils.bytesToHexString(a.getHash160())); Address b = new Address(prodParams, "LQz2pJYaeqntA9BFB8rDX5AL2TTKGd5AuN"); assertEquals("3f2ebb6c8d... | public byte[] getHash160() { return bytes; } | Address extends VersionedChecksummedBytes { public byte[] getHash160() { return bytes; } } | Address extends VersionedChecksummedBytes { public byte[] getHash160() { return bytes; } Address(NetworkParameters params, byte[] hash160); Address(NetworkParameters params, String address); } | Address extends VersionedChecksummedBytes { public byte[] getHash160() { return bytes; } Address(NetworkParameters params, byte[] hash160); Address(NetworkParameters params, String address); byte[] getHash160(); NetworkParameters getParameters(); static NetworkParameters getParametersFromAddress(String address); } | Address extends VersionedChecksummedBytes { public byte[] getHash160() { return bytes; } Address(NetworkParameters params, byte[] hash160); Address(NetworkParameters params, String address); byte[] getHash160(); NetworkParameters getParameters(); static NetworkParameters getParametersFromAddress(String address); stati... |
@Test public void getNetwork() throws Exception { NetworkParameters params = Address.getParametersFromAddress("LQz2pJYaeqntA9BFB8rDX5AL2TTKGd5AuN"); assertEquals(NetworkParameters.prodNet().getId(), params.getId()); params = Address.getParametersFromAddress("n4eA2nbYqErp7H6jebchxAN59DmNpksexv"); assertEquals(NetworkPar... | public static NetworkParameters getParametersFromAddress(String address) throws AddressFormatException { try { return new Address(null, address).getParameters(); } catch (WrongNetworkException e) { throw new RuntimeException(e); } } | Address extends VersionedChecksummedBytes { public static NetworkParameters getParametersFromAddress(String address) throws AddressFormatException { try { return new Address(null, address).getParameters(); } catch (WrongNetworkException e) { throw new RuntimeException(e); } } } | Address extends VersionedChecksummedBytes { public static NetworkParameters getParametersFromAddress(String address) throws AddressFormatException { try { return new Address(null, address).getParameters(); } catch (WrongNetworkException e) { throw new RuntimeException(e); } } Address(NetworkParameters params, byte[] ha... | Address extends VersionedChecksummedBytes { public static NetworkParameters getParametersFromAddress(String address) throws AddressFormatException { try { return new Address(null, address).getParameters(); } catch (WrongNetworkException e) { throw new RuntimeException(e); } } Address(NetworkParameters params, byte[] ha... | Address extends VersionedChecksummedBytes { public static NetworkParameters getParametersFromAddress(String address) throws AddressFormatException { try { return new Address(null, address).getParameters(); } catch (WrongNetworkException e) { throw new RuntimeException(e); } } Address(NetworkParameters params, byte[] ha... |
@Test public void testDecode() throws Exception { NetworkParameters params = NetworkParameters.unitTests(); VersionMessage ver = new VersionMessage(params, Hex.decode("71110100000000000000000048e5e95000000000000000000000000000000000000000000000ffff7f000001479d000000000000000000000000000000000000ffff7f000001479d00000000... | @Override public boolean equals(Object o) { if (!(o instanceof VersionMessage)) return false; VersionMessage other = (VersionMessage) o; return other.bestHeight == bestHeight && other.clientVersion == clientVersion && other.localServices == localServices && other.time == time && other.subVer.equals(subVer) && other.myA... | VersionMessage extends Message { @Override public boolean equals(Object o) { if (!(o instanceof VersionMessage)) return false; VersionMessage other = (VersionMessage) o; return other.bestHeight == bestHeight && other.clientVersion == clientVersion && other.localServices == localServices && other.time == time && other.s... | VersionMessage extends Message { @Override public boolean equals(Object o) { if (!(o instanceof VersionMessage)) return false; VersionMessage other = (VersionMessage) o; return other.bestHeight == bestHeight && other.clientVersion == clientVersion && other.localServices == localServices && other.time == time && other.s... | VersionMessage extends Message { @Override public boolean equals(Object o) { if (!(o instanceof VersionMessage)) return false; VersionMessage other = (VersionMessage) o; return other.bestHeight == bestHeight && other.clientVersion == clientVersion && other.localServices == localServices && other.time == time && other.s... | VersionMessage extends Message { @Override public boolean equals(Object o) { if (!(o instanceof VersionMessage)) return false; VersionMessage other = (VersionMessage) o; return other.bestHeight == bestHeight && other.clientVersion == clientVersion && other.localServices == localServices && other.time == time && other.s... |
@Test public void testWork() throws Exception { BigInteger work = params.genesisBlock.getWork(); assertEquals(BigInteger.valueOf(536879104L), work); } | public BigInteger getWork() throws VerificationException { BigInteger target = getDifficultyTargetAsInteger(); return LARGEST_HASH.divide(target.add(BigInteger.ONE)); } | Block extends Message { public BigInteger getWork() throws VerificationException { BigInteger target = getDifficultyTargetAsInteger(); return LARGEST_HASH.divide(target.add(BigInteger.ONE)); } } | Block extends Message { public BigInteger getWork() throws VerificationException { BigInteger target = getDifficultyTargetAsInteger(); return LARGEST_HASH.divide(target.add(BigInteger.ONE)); } Block(NetworkParameters params); Block(NetworkParameters params, byte[] payloadBytes); Block(NetworkParameters params, byte[]... | Block extends Message { public BigInteger getWork() throws VerificationException { BigInteger target = getDifficultyTargetAsInteger(); return LARGEST_HASH.divide(target.add(BigInteger.ONE)); } Block(NetworkParameters params); Block(NetworkParameters params, byte[] payloadBytes); Block(NetworkParameters params, byte[]... | Block extends Message { public BigInteger getWork() throws VerificationException { BigInteger target = getDifficultyTargetAsInteger(); return LARGEST_HASH.divide(target.add(BigInteger.ONE)); } Block(NetworkParameters params); Block(NetworkParameters params, byte[] payloadBytes); Block(NetworkParameters params, byte[]... |
@SuppressWarnings("deprecation") @Test public void testDate() throws Exception { Block block = new Block(params, blockBytes); assertEquals("4 Nov 2010 16:06:04 GMT", block.getTime().toGMTString()); } | public Date getTime() { return new Date(getTimeSeconds()*1000); } | Block extends Message { public Date getTime() { return new Date(getTimeSeconds()*1000); } } | Block extends Message { public Date getTime() { return new Date(getTimeSeconds()*1000); } Block(NetworkParameters params); Block(NetworkParameters params, byte[] payloadBytes); Block(NetworkParameters params, byte[] payloadBytes, boolean parseLazy, boolean parseRetain, int length); } | Block extends Message { public Date getTime() { return new Date(getTimeSeconds()*1000); } Block(NetworkParameters params); Block(NetworkParameters params, byte[] payloadBytes); Block(NetworkParameters params, byte[] payloadBytes, boolean parseLazy, boolean parseRetain, int length); BigInteger getBlockInflation(int he... | Block extends Message { public Date getTime() { return new Date(getTimeSeconds()*1000); } Block(NetworkParameters params); Block(NetworkParameters params, byte[] payloadBytes); Block(NetworkParameters params, byte[] payloadBytes, boolean parseLazy, boolean parseRetain, int length); BigInteger getBlockInflation(int he... |
@Test public void testBadTransactions() throws Exception { Block block = new Block(params, blockBytes); Transaction tx1 = block.transactions.get(0); Transaction tx2 = block.transactions.get(1); block.transactions.set(0, tx2); block.transactions.set(1, tx1); try { block.verify(); fail(); } catch (VerificationException e... | public void verify() throws VerificationException { verifyHeader(); verifyTransactions(); } | Block extends Message { public void verify() throws VerificationException { verifyHeader(); verifyTransactions(); } } | Block extends Message { public void verify() throws VerificationException { verifyHeader(); verifyTransactions(); } Block(NetworkParameters params); Block(NetworkParameters params, byte[] payloadBytes); Block(NetworkParameters params, byte[] payloadBytes, boolean parseLazy, boolean parseRetain, int length); } | Block extends Message { public void verify() throws VerificationException { verifyHeader(); verifyTransactions(); } Block(NetworkParameters params); Block(NetworkParameters params, byte[] payloadBytes); Block(NetworkParameters params, byte[] payloadBytes, boolean parseLazy, boolean parseRetain, int length); BigIntege... | Block extends Message { public void verify() throws VerificationException { verifyHeader(); verifyTransactions(); } Block(NetworkParameters params); Block(NetworkParameters params, byte[] payloadBytes); Block(NetworkParameters params, byte[] payloadBytes, boolean parseLazy, boolean parseRetain, int length); BigIntege... |
@Test public void getPeers_length() throws Exception{ SeedPeers seedPeers = new SeedPeers(NetworkParameters.prodNet()); InetSocketAddress[] addresses = seedPeers.getPeers(0, TimeUnit.SECONDS); assertThat(addresses.length, equalTo(SeedPeers.seedAddrs.length)); } | public InetSocketAddress[] getPeers(long timeoutValue, TimeUnit timeoutUnit) throws PeerDiscoveryException { try { return allPeers(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } | SeedPeers implements PeerDiscovery { public InetSocketAddress[] getPeers(long timeoutValue, TimeUnit timeoutUnit) throws PeerDiscoveryException { try { return allPeers(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } } | SeedPeers implements PeerDiscovery { public InetSocketAddress[] getPeers(long timeoutValue, TimeUnit timeoutUnit) throws PeerDiscoveryException { try { return allPeers(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } SeedPeers(NetworkParameters params); } | SeedPeers implements PeerDiscovery { public InetSocketAddress[] getPeers(long timeoutValue, TimeUnit timeoutUnit) throws PeerDiscoveryException { try { return allPeers(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } SeedPeers(NetworkParameters params); InetSocketAddress getPeer(); InetSoc... | SeedPeers implements PeerDiscovery { public InetSocketAddress[] getPeers(long timeoutValue, TimeUnit timeoutUnit) throws PeerDiscoveryException { try { return allPeers(); } catch (UnknownHostException e) { throw new PeerDiscoveryException(e); } } SeedPeers(NetworkParameters params); InetSocketAddress getPeer(); InetSoc... |
@Test public void testJavaSerialiazation() throws Exception { Block block = new Block(params, blockBytes); Transaction tx = block.transactions.get(1); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(tx); oos.close(); byte[] javaBits = bos.to... | private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { ois.defaultReadObject(); hash = null; } | Block extends Message { private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { ois.defaultReadObject(); hash = null; } } | Block extends Message { private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { ois.defaultReadObject(); hash = null; } Block(NetworkParameters params); Block(NetworkParameters params, byte[] payloadBytes); Block(NetworkParameters params, byte[] payloadBytes, boolean parseLazy, boo... | Block extends Message { private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { ois.defaultReadObject(); hash = null; } Block(NetworkParameters params); Block(NetworkParameters params, byte[] payloadBytes); Block(NetworkParameters params, byte[] payloadBytes, boolean parseLazy, boo... | Block extends Message { private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { ois.defaultReadObject(); hash = null; } Block(NetworkParameters params); Block(NetworkParameters params, byte[] payloadBytes); Block(NetworkParameters params, byte[] payloadBytes, boolean parseLazy, boo... |
@Test public void testAddEventListener() throws Exception { control.replay(); connect(); PeerEventListener listener = new AbstractPeerEventListener(); peer.addEventListener(listener); assertTrue(peer.removeEventListener(listener)); assertFalse(peer.removeEventListener(listener)); } | public void addEventListener(PeerEventListener listener) { eventListeners.add(listener); } | Peer { public void addEventListener(PeerEventListener listener) { eventListeners.add(listener); } } | Peer { public void addEventListener(PeerEventListener listener) { eventListeners.add(listener); } Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver); Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver, MemoryPool mempool); Peer(NetworkParameters params, AbstractBlock... | Peer { public void addEventListener(PeerEventListener listener) { eventListeners.add(listener); } Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver); Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver, MemoryPool mempool); Peer(NetworkParameters params, AbstractBlock... | Peer { public void addEventListener(PeerEventListener listener) { eventListeners.add(listener); } Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver); Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver, MemoryPool mempool); Peer(NetworkParameters params, AbstractBlock... |
@Test public void chainDownloadEnd2End() throws Exception { Block b1 = createFakeBlock(blockStore).block; blockChain.add(b1); Block b2 = makeSolvedTestBlock(b1); Block b3 = makeSolvedTestBlock(b2); Block b4 = makeSolvedTestBlock(b3); Block b5 = makeSolvedTestBlock(b4); control.replay(); connect(); peer.startBlockChainD... | public void startBlockChainDownload() throws IOException { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (PeerEventListener listener : eventListeners) listener.onChainDownloadStarted(this, blocksLeft); blockChainDownload(Sha256Hash.ZERO_HASH); } } | Peer { public void startBlockChainDownload() throws IOException { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (PeerEventListener listener : eventListeners) listener.onChainDownloadStarted(this, blocksLeft); blockChainDownload(Sha256Hash.ZERO_HASH); } } } | Peer { public void startBlockChainDownload() throws IOException { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (PeerEventListener listener : eventListeners) listener.onChainDownloadStarted(this, blocksLeft); blockChainDownload(Sha256Hash.ZERO_HASH); } } Peer(N... | Peer { public void startBlockChainDownload() throws IOException { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (PeerEventListener listener : eventListeners) listener.onChainDownloadStarted(this, blocksLeft); blockChainDownload(Sha256Hash.ZERO_HASH); } } Peer(N... | Peer { public void startBlockChainDownload() throws IOException { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (PeerEventListener listener : eventListeners) listener.onChainDownloadStarted(this, blocksLeft); blockChainDownload(Sha256Hash.ZERO_HASH); } } Peer(N... |
@Test public void invNoDownload() throws Exception { peer.setDownloadData(false); control.replay(); connect(); Block b1 = createFakeBlock(blockStore).block; blockChain.add(b1); Block b2 = makeSolvedTestBlock(b1); InventoryMessage inv = new InventoryMessage(unitTestParams); InventoryItem item = new InventoryItem(Invento... | public void setDownloadData(boolean downloadData) { this.vDownloadData = downloadData; } | Peer { public void setDownloadData(boolean downloadData) { this.vDownloadData = downloadData; } } | Peer { public void setDownloadData(boolean downloadData) { this.vDownloadData = downloadData; } Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver); Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver, MemoryPool mempool); Peer(NetworkParameters params, AbstractBlockCh... | Peer { public void setDownloadData(boolean downloadData) { this.vDownloadData = downloadData; } Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver); Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver, MemoryPool mempool); Peer(NetworkParameters params, AbstractBlockCh... | Peer { public void setDownloadData(boolean downloadData) { this.vDownloadData = downloadData; } Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver); Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver, MemoryPool mempool); Peer(NetworkParameters params, AbstractBlockCh... |
@Test public void invDownloadTx() throws Exception { control.replay(); connect(); peer.setDownloadData(true); BigInteger value = Utils.toNanoCoins(1, 0); Transaction tx = createFakeTx(unitTestParams, value, address); InventoryMessage inv = new InventoryMessage(unitTestParams); InventoryItem item = new InventoryItem(Inv... | public void setDownloadData(boolean downloadData) { this.vDownloadData = downloadData; } | Peer { public void setDownloadData(boolean downloadData) { this.vDownloadData = downloadData; } } | Peer { public void setDownloadData(boolean downloadData) { this.vDownloadData = downloadData; } Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver); Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver, MemoryPool mempool); Peer(NetworkParameters params, AbstractBlockCh... | Peer { public void setDownloadData(boolean downloadData) { this.vDownloadData = downloadData; } Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver); Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver, MemoryPool mempool); Peer(NetworkParameters params, AbstractBlockCh... | Peer { public void setDownloadData(boolean downloadData) { this.vDownloadData = downloadData; } Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver); Peer(NetworkParameters params, AbstractBlockChain chain, VersionMessage ver, MemoryPool mempool); Peer(NetworkParameters params, AbstractBlockCh... |
@Test public void startBlockChainDownload() throws Exception { PeerEventListener listener = control.createMock(PeerEventListener.class); Block b1 = createFakeBlock(blockStore).block; blockChain.add(b1); Block b2 = makeSolvedTestBlock(b1); blockChain.add(b2); listener.onChainDownloadStarted(peer, 108); expectLastCall();... | public void startBlockChainDownload() throws IOException { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (PeerEventListener listener : eventListeners) listener.onChainDownloadStarted(this, blocksLeft); blockChainDownload(Sha256Hash.ZERO_HASH); } } | Peer { public void startBlockChainDownload() throws IOException { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (PeerEventListener listener : eventListeners) listener.onChainDownloadStarted(this, blocksLeft); blockChainDownload(Sha256Hash.ZERO_HASH); } } } | Peer { public void startBlockChainDownload() throws IOException { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (PeerEventListener listener : eventListeners) listener.onChainDownloadStarted(this, blocksLeft); blockChainDownload(Sha256Hash.ZERO_HASH); } } Peer(N... | Peer { public void startBlockChainDownload() throws IOException { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (PeerEventListener listener : eventListeners) listener.onChainDownloadStarted(this, blocksLeft); blockChainDownload(Sha256Hash.ZERO_HASH); } } Peer(N... | Peer { public void startBlockChainDownload() throws IOException { setDownloadData(true); final int blocksLeft = getPeerBlockHeightDifference(); if (blocksLeft >= 0) { for (PeerEventListener listener : eventListeners) listener.onChainDownloadStarted(this, blocksLeft); blockChainDownload(Sha256Hash.ZERO_HASH); } } Peer(N... |
@Test public void getBlock() throws Exception { control.replay(); connect(); Block b1 = createFakeBlock(blockStore).block; blockChain.add(b1); Block b2 = makeSolvedTestBlock(b1); Block b3 = makeSolvedTestBlock(b2); Future<Block> resultFuture = peer.getBlock(b3.getHash()); assertFalse(resultFuture.isDone()); GetDataMess... | public ListenableFuture<Block> getBlock(Sha256Hash blockHash) throws IOException { log.info("Request to fetch block {}", blockHash); GetDataMessage getdata = new GetDataMessage(params); getdata.addBlock(blockHash); return sendSingleGetData(getdata); } | Peer { public ListenableFuture<Block> getBlock(Sha256Hash blockHash) throws IOException { log.info("Request to fetch block {}", blockHash); GetDataMessage getdata = new GetDataMessage(params); getdata.addBlock(blockHash); return sendSingleGetData(getdata); } } | Peer { public ListenableFuture<Block> getBlock(Sha256Hash blockHash) throws IOException { log.info("Request to fetch block {}", blockHash); GetDataMessage getdata = new GetDataMessage(params); getdata.addBlock(blockHash); return sendSingleGetData(getdata); } Peer(NetworkParameters params, AbstractBlockChain chain, Vers... | Peer { public ListenableFuture<Block> getBlock(Sha256Hash blockHash) throws IOException { log.info("Request to fetch block {}", blockHash); GetDataMessage getdata = new GetDataMessage(params); getdata.addBlock(blockHash); return sendSingleGetData(getdata); } Peer(NetworkParameters params, AbstractBlockChain chain, Vers... | Peer { public ListenableFuture<Block> getBlock(Sha256Hash blockHash) throws IOException { log.info("Request to fetch block {}", blockHash); GetDataMessage getdata = new GetDataMessage(params); getdata.addBlock(blockHash); return sendSingleGetData(getdata); } Peer(NetworkParameters params, AbstractBlockChain chain, Vers... |
@Test public void disconnectOldVersions2() throws Exception { expect(channel.close()).andReturn(null); control.replay(); handler.connectRequested(ctx, new UpstreamChannelStateEvent(channel, ChannelState.CONNECTED, socketAddress)); VersionMessage peerVersion = new VersionMessage(unitTestParams, OTHER_PEER_CHAIN_HEIGHT);... | public ChannelFuture setMinProtocolVersion(int minProtocolVersion) { this.vMinProtocolVersion = minProtocolVersion; if (getVersionMessage().clientVersion < minProtocolVersion) { log.warn("{}: Disconnecting due to new min protocol version {}", this, minProtocolVersion); return Channels.close(vChannel); } else { return n... | Peer { public ChannelFuture setMinProtocolVersion(int minProtocolVersion) { this.vMinProtocolVersion = minProtocolVersion; if (getVersionMessage().clientVersion < minProtocolVersion) { log.warn("{}: Disconnecting due to new min protocol version {}", this, minProtocolVersion); return Channels.close(vChannel); } else { r... | Peer { public ChannelFuture setMinProtocolVersion(int minProtocolVersion) { this.vMinProtocolVersion = minProtocolVersion; if (getVersionMessage().clientVersion < minProtocolVersion) { log.warn("{}: Disconnecting due to new min protocol version {}", this, minProtocolVersion); return Channels.close(vChannel); } else { r... | Peer { public ChannelFuture setMinProtocolVersion(int minProtocolVersion) { this.vMinProtocolVersion = minProtocolVersion; if (getVersionMessage().clientVersion < minProtocolVersion) { log.warn("{}: Disconnecting due to new min protocol version {}", this, minProtocolVersion); return Channels.close(vChannel); } else { r... | Peer { public ChannelFuture setMinProtocolVersion(int minProtocolVersion) { this.vMinProtocolVersion = minProtocolVersion; if (getVersionMessage().clientVersion < minProtocolVersion) { log.warn("{}: Disconnecting due to new min protocol version {}", this, minProtocolVersion); return Channels.close(vChannel); } else { r... |
@Test public void peerDiscoveryPolling() throws Exception { final Semaphore sem = new Semaphore(0); final boolean[] result = new boolean[1]; result[0] = false; peerGroup.addPeerDiscovery(new PeerDiscovery() { public InetSocketAddress[] getPeers(long unused, TimeUnit unused2) throws PeerDiscoveryException { if (result[0... | public void addPeerDiscovery(PeerDiscovery peerDiscovery) { lock.lock(); try { if (getMaxConnections() == 0) setMaxConnections(DEFAULT_CONNECTIONS); peerDiscoverers.add(peerDiscovery); } finally { lock.unlock(); } } | PeerGroup extends AbstractIdleService { public void addPeerDiscovery(PeerDiscovery peerDiscovery) { lock.lock(); try { if (getMaxConnections() == 0) setMaxConnections(DEFAULT_CONNECTIONS); peerDiscoverers.add(peerDiscovery); } finally { lock.unlock(); } } } | PeerGroup extends AbstractIdleService { public void addPeerDiscovery(PeerDiscovery peerDiscovery) { lock.lock(); try { if (getMaxConnections() == 0) setMaxConnections(DEFAULT_CONNECTIONS); peerDiscoverers.add(peerDiscovery); } finally { lock.unlock(); } } PeerGroup(NetworkParameters params); PeerGroup(NetworkParameter... | PeerGroup extends AbstractIdleService { public void addPeerDiscovery(PeerDiscovery peerDiscovery) { lock.lock(); try { if (getMaxConnections() == 0) setMaxConnections(DEFAULT_CONNECTIONS); peerDiscoverers.add(peerDiscovery); } finally { lock.unlock(); } } PeerGroup(NetworkParameters params); PeerGroup(NetworkParameter... | PeerGroup extends AbstractIdleService { public void addPeerDiscovery(PeerDiscovery peerDiscovery) { lock.lock(); try { if (getMaxConnections() == 0) setMaxConnections(DEFAULT_CONNECTIONS); peerDiscoverers.add(peerDiscovery); } finally { lock.unlock(); } } PeerGroup(NetworkParameters params); PeerGroup(NetworkParameter... |
@Test public void singleDownloadPeer1() throws Exception { peerGroup.startAndWait(); FakeChannel p1 = connectPeer(1); FakeChannel p2 = connectPeer(2); assertEquals(2, peerGroup.numConnectedPeers()); Block b1 = TestUtils.createFakeBlock(blockStore).block; blockChain.add(b1); Block b2 = TestUtils.makeSolvedTestBlock(b1);... | public int numConnectedPeers() { return peers.size(); } | PeerGroup extends AbstractIdleService { public int numConnectedPeers() { return peers.size(); } } | PeerGroup extends AbstractIdleService { public int numConnectedPeers() { return peers.size(); } PeerGroup(NetworkParameters params); PeerGroup(NetworkParameters params, AbstractBlockChain chain); PeerGroup(NetworkParameters params, AbstractBlockChain chain, ClientBootstrap bootstrap); } | PeerGroup extends AbstractIdleService { public int numConnectedPeers() { return peers.size(); } PeerGroup(NetworkParameters params); PeerGroup(NetworkParameters params, AbstractBlockChain chain); PeerGroup(NetworkParameters params, AbstractBlockChain chain, ClientBootstrap bootstrap); static ClientBootstrap createCli... | PeerGroup extends AbstractIdleService { public int numConnectedPeers() { return peers.size(); } PeerGroup(NetworkParameters params); PeerGroup(NetworkParameters params, AbstractBlockChain chain); PeerGroup(NetworkParameters params, AbstractBlockChain chain, ClientBootstrap bootstrap); static ClientBootstrap createCli... |
@Test public void testParseUserList() throws UnknownHostException { String[] userList = new String[]{ "x201500200","u4stwEBjT6FYyVV", "u5BKEqDApa8SbA7"}; ArrayList<InetSocketAddress> addresses = IrcDiscovery.parseUserList(userList); assertEquals("Too many addresses.", 2, addresses.size()); String[] ips = new String[]{"... | static ArrayList<InetSocketAddress> parseUserList(String[] userNames) throws UnknownHostException { ArrayList<InetSocketAddress> addresses = new ArrayList<InetSocketAddress>(); for (String user : userNames) { if (!user.startsWith("u")) { continue; } byte[] addressBytes; try { addressBytes = Base58.decodeChecked(user.su... | IrcDiscovery implements PeerDiscovery { static ArrayList<InetSocketAddress> parseUserList(String[] userNames) throws UnknownHostException { ArrayList<InetSocketAddress> addresses = new ArrayList<InetSocketAddress>(); for (String user : userNames) { if (!user.startsWith("u")) { continue; } byte[] addressBytes; try { add... | IrcDiscovery implements PeerDiscovery { static ArrayList<InetSocketAddress> parseUserList(String[] userNames) throws UnknownHostException { ArrayList<InetSocketAddress> addresses = new ArrayList<InetSocketAddress>(); for (String user : userNames) { if (!user.startsWith("u")) { continue; } byte[] addressBytes; try { add... | IrcDiscovery implements PeerDiscovery { static ArrayList<InetSocketAddress> parseUserList(String[] userNames) throws UnknownHostException { ArrayList<InetSocketAddress> addresses = new ArrayList<InetSocketAddress>(); for (String user : userNames) { if (!user.startsWith("u")) { continue; } byte[] addressBytes; try { add... | IrcDiscovery implements PeerDiscovery { static ArrayList<InetSocketAddress> parseUserList(String[] userNames) throws UnknownHostException { ArrayList<InetSocketAddress> addresses = new ArrayList<InetSocketAddress>(); for (String user : userNames) { if (!user.startsWith("u")) { continue; } byte[] addressBytes; try { add... |
@Test public void singleDownloadPeer2() throws Exception { peerGroup.startAndWait(); FakeChannel p1 = connectPeer(1); Block b1 = TestUtils.createFakeBlock(blockStore).block; Block b2 = TestUtils.makeSolvedTestBlock(b1); Block b3 = TestUtils.makeSolvedTestBlock(b2); peerGroup.startBlockChainDownload(new AbstractPeerEven... | public void startBlockChainDownload(PeerEventListener listener) { lock.lock(); try { this.downloadListener = listener; synchronized (peers) { if (!peers.isEmpty()) { startBlockChainDownloadFromPeer(peers.iterator().next()); } } } finally { lock.unlock(); } } | PeerGroup extends AbstractIdleService { public void startBlockChainDownload(PeerEventListener listener) { lock.lock(); try { this.downloadListener = listener; synchronized (peers) { if (!peers.isEmpty()) { startBlockChainDownloadFromPeer(peers.iterator().next()); } } } finally { lock.unlock(); } } } | PeerGroup extends AbstractIdleService { public void startBlockChainDownload(PeerEventListener listener) { lock.lock(); try { this.downloadListener = listener; synchronized (peers) { if (!peers.isEmpty()) { startBlockChainDownloadFromPeer(peers.iterator().next()); } } } finally { lock.unlock(); } } PeerGroup(NetworkPara... | PeerGroup extends AbstractIdleService { public void startBlockChainDownload(PeerEventListener listener) { lock.lock(); try { this.downloadListener = listener; synchronized (peers) { if (!peers.isEmpty()) { startBlockChainDownloadFromPeer(peers.iterator().next()); } } } finally { lock.unlock(); } } PeerGroup(NetworkPara... | PeerGroup extends AbstractIdleService { public void startBlockChainDownload(PeerEventListener listener) { lock.lock(); try { this.downloadListener = listener; synchronized (peers) { if (!peers.isEmpty()) { startBlockChainDownloadFromPeer(peers.iterator().next()); } } } finally { lock.unlock(); } } PeerGroup(NetworkPara... |
@Test public void testHeaders1() throws Exception { LitecoinSerializer bs = new LitecoinSerializer(NetworkParameters.prodNet()); ByteArrayInputStream bais = new ByteArrayInputStream(Hex.decode("fbc0b6db686561" + "646572730000000000520000005d4fab8101010000006fe28c0ab6f1b372c1a6a246ae6" + "3f74f931e8365e15a089c68d6190000... | public Message deserialize(InputStream in) throws ProtocolException, IOException { seekPastMagicBytes(in); LitecoinPacketHeader header = new LitecoinPacketHeader(in); return deserializePayload(header, in); } | LitecoinSerializer { public Message deserialize(InputStream in) throws ProtocolException, IOException { seekPastMagicBytes(in); LitecoinPacketHeader header = new LitecoinPacketHeader(in); return deserializePayload(header, in); } } | LitecoinSerializer { public Message deserialize(InputStream in) throws ProtocolException, IOException { seekPastMagicBytes(in); LitecoinPacketHeader header = new LitecoinPacketHeader(in); return deserializePayload(header, in); } LitecoinSerializer(NetworkParameters params); LitecoinSerializer(NetworkParameters params,... | LitecoinSerializer { public Message deserialize(InputStream in) throws ProtocolException, IOException { seekPastMagicBytes(in); LitecoinPacketHeader header = new LitecoinPacketHeader(in); return deserializePayload(header, in); } LitecoinSerializer(NetworkParameters params); LitecoinSerializer(NetworkParameters params,... | LitecoinSerializer { public Message deserialize(InputStream in) throws ProtocolException, IOException { seekPastMagicBytes(in); LitecoinPacketHeader header = new LitecoinPacketHeader(in); return deserializePayload(header, in); } LitecoinSerializer(NetworkParameters params); LitecoinSerializer(NetworkParameters params,... |
@Test public void testHeaders2() throws Exception { LitecoinSerializer bs = new LitecoinSerializer(NetworkParameters.prodNet()); ByteArrayInputStream bais = new ByteArrayInputStream(Hex.decode("fbc0b6db6865616465" + "72730000000000e701000085acd4ea06010000006fe28c0ab6f1b372c1a6a246ae63f74f931e" + "8365e15a089c68d6190000... | public Message deserialize(InputStream in) throws ProtocolException, IOException { seekPastMagicBytes(in); LitecoinPacketHeader header = new LitecoinPacketHeader(in); return deserializePayload(header, in); } | LitecoinSerializer { public Message deserialize(InputStream in) throws ProtocolException, IOException { seekPastMagicBytes(in); LitecoinPacketHeader header = new LitecoinPacketHeader(in); return deserializePayload(header, in); } } | LitecoinSerializer { public Message deserialize(InputStream in) throws ProtocolException, IOException { seekPastMagicBytes(in); LitecoinPacketHeader header = new LitecoinPacketHeader(in); return deserializePayload(header, in); } LitecoinSerializer(NetworkParameters params); LitecoinSerializer(NetworkParameters params,... | LitecoinSerializer { public Message deserialize(InputStream in) throws ProtocolException, IOException { seekPastMagicBytes(in); LitecoinPacketHeader header = new LitecoinPacketHeader(in); return deserializePayload(header, in); } LitecoinSerializer(NetworkParameters params); LitecoinSerializer(NetworkParameters params,... | LitecoinSerializer { public Message deserialize(InputStream in) throws ProtocolException, IOException { seekPastMagicBytes(in); LitecoinPacketHeader header = new LitecoinPacketHeader(in); return deserializePayload(header, in); } LitecoinSerializer(NetworkParameters params); LitecoinSerializer(NetworkParameters params,... |
@Test public void verifyMessage() throws Exception { String message = "hello"; String sigBase64 = "HxNZdo6ggZ41hd3mM3gfJRqOQPZYcO8z8qdX2BwmpbF11CaOQV+QiZGGQxaYOncKoNW61oRuSMMF8udfK54XqI8="; Address expectedAddress = new Address(NetworkParameters.prodNet(), "LNmLhahYB2gb3Hf3ZJsGaTyhG3HPDEPXfn"); ECKey key = ECKey.signed... | public void verifyMessage(String message, String signatureBase64) throws SignatureException { ECKey key = ECKey.signedMessageToKey(message, signatureBase64); if (!Arrays.equals(key.getPubKey(), pub)) throw new SignatureException("Signature did not match for message"); } | ECKey implements Serializable { public void verifyMessage(String message, String signatureBase64) throws SignatureException { ECKey key = ECKey.signedMessageToKey(message, signatureBase64); if (!Arrays.equals(key.getPubKey(), pub)) throw new SignatureException("Signature did not match for message"); } } | ECKey implements Serializable { public void verifyMessage(String message, String signatureBase64) throws SignatureException { ECKey key = ECKey.signedMessageToKey(message, signatureBase64); if (!Arrays.equals(key.getPubKey(), pub)) throw new SignatureException("Signature did not match for message"); } ECKey(); ECKey(B... | ECKey implements Serializable { public void verifyMessage(String message, String signatureBase64) throws SignatureException { ECKey key = ECKey.signedMessageToKey(message, signatureBase64); if (!Arrays.equals(key.getPubKey(), pub)) throw new SignatureException("Signature did not match for message"); } ECKey(); ECKey(B... | ECKey implements Serializable { public void verifyMessage(String message, String signatureBase64) throws SignatureException { ECKey key = ECKey.signedMessageToKey(message, signatureBase64); if (!Arrays.equals(key.getPubKey(), pub)) throw new SignatureException("Signature did not match for message"); } ECKey(); ECKey(B... |
@Test public void testEncryptionIsReversible() throws Exception { ECKey originalUnencryptedKey = new ECKey(); EncryptedPrivateKey encryptedPrivateKey = keyCrypter.encrypt(originalUnencryptedKey.getPrivKeyBytes(), keyCrypter.deriveKey(PASSWORD1)); ECKey encryptedKey = new ECKey(encryptedPrivateKey, originalUnencryptedKe... | public static boolean encryptionIsReversible(ECKey originalKey, ECKey encryptedKey, KeyCrypter keyCrypter, KeyParameter aesKey) { String genericErrorText = "The check that encryption could be reversed failed for key " + originalKey.toString() + ". "; try { ECKey rebornUnencryptedKey = encryptedKey.decrypt(keyCrypter, a... | ECKey implements Serializable { public static boolean encryptionIsReversible(ECKey originalKey, ECKey encryptedKey, KeyCrypter keyCrypter, KeyParameter aesKey) { String genericErrorText = "The check that encryption could be reversed failed for key " + originalKey.toString() + ". "; try { ECKey rebornUnencryptedKey = en... | ECKey implements Serializable { public static boolean encryptionIsReversible(ECKey originalKey, ECKey encryptedKey, KeyCrypter keyCrypter, KeyParameter aesKey) { String genericErrorText = "The check that encryption could be reversed failed for key " + originalKey.toString() + ". "; try { ECKey rebornUnencryptedKey = en... | ECKey implements Serializable { public static boolean encryptionIsReversible(ECKey originalKey, ECKey encryptedKey, KeyCrypter keyCrypter, KeyParameter aesKey) { String genericErrorText = "The check that encryption could be reversed failed for key " + originalKey.toString() + ". "; try { ECKey rebornUnencryptedKey = en... | ECKey implements Serializable { public static boolean encryptionIsReversible(ECKey originalKey, ECKey encryptedKey, KeyCrypter keyCrypter, KeyParameter aesKey) { String genericErrorText = "The check that encryption could be reversed failed for key " + originalKey.toString() + ". "; try { ECKey rebornUnencryptedKey = en... |
@Test public void testToString() throws Exception { ECKey key = new ECKey(BigInteger.TEN); assertEquals("pub:04a0434d9e47f3c86235477c7b1ae6ae5d3442d49b1943c2b752a68e2a47e247c7893aba425419bc27a3b6c7e693a24c696f794c2ed877a1593cbee53b037368d7", key.toString()); assertEquals("pub:04a0434d9e47f3c86235477c7b1ae6ae5d3442d49b1... | public String toString() { StringBuilder b = new StringBuilder(); b.append("pub:").append(Utils.bytesToHexString(pub)); if (creationTimeSeconds != 0) { b.append(" timestamp:").append(creationTimeSeconds); } if (isEncrypted()) { b.append(" encrypted"); } return b.toString(); } | ECKey implements Serializable { public String toString() { StringBuilder b = new StringBuilder(); b.append("pub:").append(Utils.bytesToHexString(pub)); if (creationTimeSeconds != 0) { b.append(" timestamp:").append(creationTimeSeconds); } if (isEncrypted()) { b.append(" encrypted"); } return b.toString(); } } | ECKey implements Serializable { public String toString() { StringBuilder b = new StringBuilder(); b.append("pub:").append(Utils.bytesToHexString(pub)); if (creationTimeSeconds != 0) { b.append(" timestamp:").append(creationTimeSeconds); } if (isEncrypted()) { b.append(" encrypted"); } return b.toString(); } ECKey(); E... | ECKey implements Serializable { public String toString() { StringBuilder b = new StringBuilder(); b.append("pub:").append(Utils.bytesToHexString(pub)); if (creationTimeSeconds != 0) { b.append(" timestamp:").append(creationTimeSeconds); } if (isEncrypted()) { b.append(" encrypted"); } return b.toString(); } ECKey(); E... | ECKey implements Serializable { public String toString() { StringBuilder b = new StringBuilder(); b.append("pub:").append(Utils.bytesToHexString(pub)); if (creationTimeSeconds != 0) { b.append(" timestamp:").append(creationTimeSeconds); } if (isEncrypted()) { b.append(" encrypted"); } return b.toString(); } ECKey(); E... |
@Test public void testToNanoCoins() { assertEquals(CENT, toNanoCoins("0.01")); assertEquals(CENT, toNanoCoins("1E-2")); assertEquals(COIN.add(Utils.CENT), toNanoCoins("1.01")); try { toNanoCoins("2E-20"); org.junit.Assert.fail("should not have accepted fractional nanocoins"); } catch (ArithmeticException e) { } assertE... | public static BigInteger toNanoCoins(int coins, int cents) { checkArgument(cents < 100); BigInteger bi = BigInteger.valueOf(coins).multiply(COIN); bi = bi.add(BigInteger.valueOf(cents).multiply(CENT)); return bi; } | Utils { public static BigInteger toNanoCoins(int coins, int cents) { checkArgument(cents < 100); BigInteger bi = BigInteger.valueOf(coins).multiply(COIN); bi = bi.add(BigInteger.valueOf(cents).multiply(CENT)); return bi; } } | Utils { public static BigInteger toNanoCoins(int coins, int cents) { checkArgument(cents < 100); BigInteger bi = BigInteger.valueOf(coins).multiply(COIN); bi = bi.add(BigInteger.valueOf(cents).multiply(CENT)); return bi; } } | Utils { public static BigInteger toNanoCoins(int coins, int cents) { checkArgument(cents < 100); BigInteger bi = BigInteger.valueOf(coins).multiply(COIN); bi = bi.add(BigInteger.valueOf(cents).multiply(CENT)); return bi; } static BigInteger toNanoCoins(int coins, int cents); static byte[] bigIntegerToBytes(BigInteger ... | Utils { public static BigInteger toNanoCoins(int coins, int cents) { checkArgument(cents < 100); BigInteger bi = BigInteger.valueOf(coins).multiply(COIN); bi = bi.add(BigInteger.valueOf(cents).multiply(CENT)); return bi; } static BigInteger toNanoCoins(int coins, int cents); static byte[] bigIntegerToBytes(BigInteger ... |
@Test public void testLitecoinValueToPlainString() { try { litecoinValueToPlainString(null); org.junit.Assert.fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("Value cannot be null")); } assertEquals("0.0015", litecoinValueToPlainString(BigInteger.val... | public static String litecoinValueToPlainString(BigInteger value) { if (value == null) { throw new IllegalArgumentException("Value cannot be null"); } BigDecimal valueInBTC = new BigDecimal(value).divide(new BigDecimal(Utils.COIN)); return valueInBTC.toPlainString(); } | Utils { public static String litecoinValueToPlainString(BigInteger value) { if (value == null) { throw new IllegalArgumentException("Value cannot be null"); } BigDecimal valueInBTC = new BigDecimal(value).divide(new BigDecimal(Utils.COIN)); return valueInBTC.toPlainString(); } } | Utils { public static String litecoinValueToPlainString(BigInteger value) { if (value == null) { throw new IllegalArgumentException("Value cannot be null"); } BigDecimal valueInBTC = new BigDecimal(value).divide(new BigDecimal(Utils.COIN)); return valueInBTC.toPlainString(); } } | Utils { public static String litecoinValueToPlainString(BigInteger value) { if (value == null) { throw new IllegalArgumentException("Value cannot be null"); } BigDecimal valueInBTC = new BigDecimal(value).divide(new BigDecimal(Utils.COIN)); return valueInBTC.toPlainString(); } static BigInteger toNanoCoins(int coins, ... | Utils { public static String litecoinValueToPlainString(BigInteger value) { if (value == null) { throw new IllegalArgumentException("Value cannot be null"); } BigDecimal valueInBTC = new BigDecimal(value).divide(new BigDecimal(Utils.COIN)); return valueInBTC.toPlainString(); } static BigInteger toNanoCoins(int coins, ... |
@Test public void testReverseBytes() { Assert.assertArrayEquals(new byte[] {1,2,3,4,5}, Utils.reverseBytes(new byte[] {5,4,3,2,1})); } | public static byte[] reverseBytes(byte[] bytes) { byte[] buf = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) buf[i] = bytes[bytes.length - 1 - i]; return buf; } | Utils { public static byte[] reverseBytes(byte[] bytes) { byte[] buf = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) buf[i] = bytes[bytes.length - 1 - i]; return buf; } } | Utils { public static byte[] reverseBytes(byte[] bytes) { byte[] buf = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) buf[i] = bytes[bytes.length - 1 - i]; return buf; } } | Utils { public static byte[] reverseBytes(byte[] bytes) { byte[] buf = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) buf[i] = bytes[bytes.length - 1 - i]; return buf; } static BigInteger toNanoCoins(int coins, int cents); static byte[] bigIntegerToBytes(BigInteger b, int numBytes); static BigInteger t... | Utils { public static byte[] reverseBytes(byte[] bytes) { byte[] buf = new byte[bytes.length]; for (int i = 0; i < bytes.length; i++) buf[i] = bytes[bytes.length - 1 - i]; return buf; } static BigInteger toNanoCoins(int coins, int cents); static byte[] bigIntegerToBytes(BigInteger b, int numBytes); static BigInteger t... |
@Test public void testReverseDwordBytes() { Assert.assertArrayEquals(new byte[] {1,2,3,4,5,6,7,8}, Utils.reverseDwordBytes(new byte[] {4,3,2,1,8,7,6,5}, -1)); Assert.assertArrayEquals(new byte[] {1,2,3,4}, Utils.reverseDwordBytes(new byte[] {4,3,2,1,8,7,6,5}, 4)); Assert.assertArrayEquals(new byte[0], Utils.reverseDwor... | public static byte[] reverseDwordBytes(byte[] bytes, int trimLength) { checkArgument(bytes.length % 4 == 0); checkArgument(trimLength < 0 || trimLength % 4 == 0); byte[] rev = new byte[trimLength >= 0 && bytes.length > trimLength ? trimLength : bytes.length]; for (int i = 0; i < rev.length; i += 4) { System.arraycopy(b... | Utils { public static byte[] reverseDwordBytes(byte[] bytes, int trimLength) { checkArgument(bytes.length % 4 == 0); checkArgument(trimLength < 0 || trimLength % 4 == 0); byte[] rev = new byte[trimLength >= 0 && bytes.length > trimLength ? trimLength : bytes.length]; for (int i = 0; i < rev.length; i += 4) { System.arr... | Utils { public static byte[] reverseDwordBytes(byte[] bytes, int trimLength) { checkArgument(bytes.length % 4 == 0); checkArgument(trimLength < 0 || trimLength % 4 == 0); byte[] rev = new byte[trimLength >= 0 && bytes.length > trimLength ? trimLength : bytes.length]; for (int i = 0; i < rev.length; i += 4) { System.arr... | Utils { public static byte[] reverseDwordBytes(byte[] bytes, int trimLength) { checkArgument(bytes.length % 4 == 0); checkArgument(trimLength < 0 || trimLength % 4 == 0); byte[] rev = new byte[trimLength >= 0 && bytes.length > trimLength ? trimLength : bytes.length]; for (int i = 0; i < rev.length; i += 4) { System.arr... | Utils { public static byte[] reverseDwordBytes(byte[] bytes, int trimLength) { checkArgument(bytes.length % 4 == 0); checkArgument(trimLength < 0 || trimLength % 4 == 0); byte[] rev = new byte[trimLength >= 0 && bytes.length > trimLength ? trimLength : bytes.length]; for (int i = 0; i < rev.length; i += 4) { System.arr... |
@Test public void testConvertToLitecoinURI() throws Exception { Address goodAddress = new Address(NetworkParameters.prodNet(), PRODNET_GOOD_ADDRESS); assertEquals("litecoin:" + PRODNET_GOOD_ADDRESS + "?amount=12.34&label=Hello&message=AMessage", LitecoinURI.convertToLitecoinURI(goodAddress, Utils.toNanoCoins("12.34"), ... | public static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message) { return convertToLitecoinURI(address.toString(), amount, label, message); } | LitecoinURI { public static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message) { return convertToLitecoinURI(address.toString(), amount, label, message); } } | LitecoinURI { public static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message) { return convertToLitecoinURI(address.toString(), amount, label, message); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); } | LitecoinURI { public static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message) { return convertToLitecoinURI(address.toString(), amount, label, message); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount... | LitecoinURI { public static String convertToLitecoinURI(Address address, BigInteger amount, String label, String message) { return convertToLitecoinURI(address.toString(), amount, label, message); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount... |
@Test public void testBad_BadSyntax() { try { testObject = new LitecoinURI(NetworkParameters.prodNet(), LitecoinURI.LITECOIN_SCHEME + "|" + PRODNET_GOOD_ADDRESS); fail("Expecting LitecoinURIParseException"); } catch (LitecoinURIParseException e) { assertTrue(e.getMessage().contains("Bad URI syntax")); } try { testObjec... | public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toSt... | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toSt... |
@Test public void testBad_IncorrectAddressType() { try { testObject = new LitecoinURI(NetworkParameters.testNet(), LitecoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS); fail("Expecting LitecoinURIParseException"); } catch (LitecoinURIParseException e) { assertTrue(e.getMessage().contains("Bad address")); } } | public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toSt... | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toSt... |
@Test public void testGood_Label() throws LitecoinURIParseException { testObject = new LitecoinURI(NetworkParameters.prodNet(), LitecoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?label=Hello%20World"); assertEquals("Hello World", testObject.getLabel()); } | public String getLabel() { return (String) parameterMap.get(FIELD_LABEL); } | LitecoinURI { public String getLabel() { return (String) parameterMap.get(FIELD_LABEL); } } | LitecoinURI { public String getLabel() { return (String) parameterMap.get(FIELD_LABEL); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); } | LitecoinURI { public String getLabel() { return (String) parameterMap.get(FIELD_LABEL); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toString... | LitecoinURI { public String getLabel() { return (String) parameterMap.get(FIELD_LABEL); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toString... |
@Test public void testGood_Message() throws LitecoinURIParseException { testObject = new LitecoinURI(NetworkParameters.prodNet(), LitecoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?message=Hello%20World"); assertEquals("Hello World", testObject.getMessage()); } | public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); } | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toSt... | LitecoinURI { public String getMessage() { return (String) parameterMap.get(FIELD_MESSAGE); } LitecoinURI(String uri); LitecoinURI(NetworkParameters params, String input); Address getAddress(); BigInteger getAmount(); String getLabel(); String getMessage(); Object getParameterByName(String name); @Override String toSt... |
@Test public void testGood_Combinations() throws LitecoinURIParseException { testObject = new LitecoinURI(NetworkParameters.prodNet(), LitecoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?amount=9876543210&label=Hello%20World&message=Be%20well"); assertEquals( "LitecoinURI['address'='LQz2pJYaeqntA9BFB8rDX5AL2TT... | @Override public String toString() { StringBuilder builder = new StringBuilder("LitecoinURI["); boolean first = true; for (Map.Entry<String, Object> entry : parameterMap.entrySet()) { if (first) { first = false; } else { builder.append(","); } builder.append("'").append(entry.getKey()).append("'=").append("'").append(e... | LitecoinURI { @Override public String toString() { StringBuilder builder = new StringBuilder("LitecoinURI["); boolean first = true; for (Map.Entry<String, Object> entry : parameterMap.entrySet()) { if (first) { first = false; } else { builder.append(","); } builder.append("'").append(entry.getKey()).append("'=").append... | LitecoinURI { @Override public String toString() { StringBuilder builder = new StringBuilder("LitecoinURI["); boolean first = true; for (Map.Entry<String, Object> entry : parameterMap.entrySet()) { if (first) { first = false; } else { builder.append(","); } builder.append("'").append(entry.getKey()).append("'=").append... | LitecoinURI { @Override public String toString() { StringBuilder builder = new StringBuilder("LitecoinURI["); boolean first = true; for (Map.Entry<String, Object> entry : parameterMap.entrySet()) { if (first) { first = false; } else { builder.append(","); } builder.append("'").append(entry.getKey()).append("'=").append... | LitecoinURI { @Override public String toString() { StringBuilder builder = new StringBuilder("LitecoinURI["); boolean first = true; for (Map.Entry<String, Object> entry : parameterMap.entrySet()) { if (first) { first = false; } else { builder.append(","); } builder.append("'").append(entry.getKey()).append("'=").append... |
@Test public void getRecipients() { dao.getRecipients(); } | public List<Recipient> getRecipients() { return mapper.scan(Recipient.class, new DynamoDBScanExpression()); } | CloudNoticeDAO { public List<Recipient> getRecipients() { return mapper.scan(Recipient.class, new DynamoDBScanExpression()); } } | CloudNoticeDAO { public List<Recipient> getRecipients() { return mapper.scan(Recipient.class, new DynamoDBScanExpression()); } CloudNoticeDAO(boolean local); } | CloudNoticeDAO { public List<Recipient> getRecipients() { return mapper.scan(Recipient.class, new DynamoDBScanExpression()); } CloudNoticeDAO(boolean local); List<Recipient> getRecipients(); void saveRecipient(Recipient recip); void deleteRecipient(Recipient recip); void shutdown(); } | CloudNoticeDAO { public List<Recipient> getRecipients() { return mapper.scan(Recipient.class, new DynamoDBScanExpression()); } CloudNoticeDAO(boolean local); List<Recipient> getRecipients(); void saveRecipient(Recipient recip); void deleteRecipient(Recipient recip); void shutdown(); static final String TABLE_NAME; } |
@Test public void nowWithoutSpacesAndTime() { Queue<Token> words = parser.parse("now+03:04"); Assert.assertTrue(words.poll() instanceof TimeToken); Assert.assertTrue(words.poll() instanceof OperatorToken); Assert.assertTrue(words.poll() instanceof TimeToken); } | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void nowWithoutSpacesAndUnitOfMeasure() { Queue<Token> tokens = parser.parse("now+3h4m"); Assert.assertEquals(tokens.size(), 6); Assert.assertTrue(tokens.poll() instanceof TimeToken); Assert.assertTrue(tokens.poll() instanceof OperatorToken); Assert.assertTrue(tokens.poll() instanceof IntegerToken); Assert... | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void timeAdditionWithSpaces() { Queue<Token> words = parser.parse("12:37 + 0:42"); Assert.assertTrue(words.poll() instanceof TimeToken); Assert.assertTrue(words.poll() instanceof OperatorToken); Assert.assertTrue(words.poll() instanceof TimeToken); } | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void timeAdditionWithoutSpaces() { Queue<Token> words = parser.parse("12:37+0:42"); Assert.assertTrue(words.poll() instanceof TimeToken); Assert.assertTrue(words.poll() instanceof OperatorToken); Assert.assertTrue(words.poll() instanceof TimeToken); } | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void dateMathWithSpaces() { Queue<Token> words = parser.parse("2016/09/27 - 3 months"); Assert.assertTrue(words.poll() instanceof DateToken); Assert.assertTrue(words.poll() instanceof OperatorToken); Assert.assertTrue(words.poll() instanceof IntegerToken); Assert.assertTrue(words.poll() instanceof UnitOfMe... | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void dateDiffWithoutSpaces() { Queue<Token> words = parser.parse("2016/12/25-2016/07/04"); Assert.assertTrue(words.poll() instanceof DateToken); Assert.assertTrue(words.poll() instanceof OperatorToken); Assert.assertTrue(words.poll() instanceof DateToken); } | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void dateMinusDuration() { Queue<Token> tokens = parser.parse("2016/09/27 - 3 months"); Assert.assertEquals(tokens.size(), 4); Assert.assertTrue(tokens.poll() instanceof DateToken); Assert.assertTrue(tokens.poll() instanceof OperatorToken); Assert.assertTrue(tokens.poll() instanceof IntegerToken); Assert.a... | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void dateMinusDate() { Queue<Token> tokens = parser.parse("2016/12/25-2016/07/04"); Assert.assertEquals(tokens.size(), 3); Assert.assertTrue(tokens.poll() instanceof DateToken); Assert.assertTrue(tokens.poll() instanceof OperatorToken); Assert.assertTrue(tokens.poll() instanceof DateToken); } | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void dateMinusDateWithSpaces() { Queue<Token> tokens = parser.parse("2016/12/25 - 2016/07/04"); Assert.assertEquals(tokens.size(), 3); Assert.assertTrue(tokens.poll() instanceof DateToken); Assert.assertTrue(tokens.poll() instanceof OperatorToken); Assert.assertTrue(tokens.poll() instanceof DateToken); } | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void dateMinusDateWithInvalidOperator() { try { Queue<Token> tokens = parser.parse("2016/12/25 * 2016/07/04"); Assert.fail("A DateCalcException should have been thrown for an illegal character"); } catch (DateCalcException dce) { } } | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void deleteRecipient() { Recipient recip = new Recipient("SMS", "test2@example.com"); dao.saveRecipient(recip); Assert.assertEquals(1, dao.getRecipients().size()); dao.deleteRecipient(recip); Assert.assertEquals(0, dao.getRecipients().size()); } | public void deleteRecipient(Recipient recip) { mapper.delete(recip); } | CloudNoticeDAO { public void deleteRecipient(Recipient recip) { mapper.delete(recip); } } | CloudNoticeDAO { public void deleteRecipient(Recipient recip) { mapper.delete(recip); } CloudNoticeDAO(boolean local); } | CloudNoticeDAO { public void deleteRecipient(Recipient recip) { mapper.delete(recip); } CloudNoticeDAO(boolean local); List<Recipient> getRecipients(); void saveRecipient(Recipient recip); void deleteRecipient(Recipient recip); void shutdown(); } | CloudNoticeDAO { public void deleteRecipient(Recipient recip) { mapper.delete(recip); } CloudNoticeDAO(boolean local); List<Recipient> getRecipients(); void saveRecipient(Recipient recip); void deleteRecipient(Recipient recip); void shutdown(); static final String TABLE_NAME; } |
@Test public void timePlusDuration() { Queue<Token> tokens = parser.parse("12:37+42m"); Assert.assertEquals(tokens.size(), 4); Assert.assertTrue(tokens.poll() instanceof TimeToken); Assert.assertTrue(tokens.poll() instanceof OperatorToken); Assert.assertTrue(tokens.poll() instanceof IntegerToken); Assert.assertTrue(tok... | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void timePlusDurationWithSpaces() { Queue<Token> tokens = parser.parse("12:37 + 42 m"); Assert.assertEquals(tokens.size(), 4); Assert.assertTrue(tokens.poll() instanceof TimeToken); Assert.assertTrue(tokens.poll() instanceof OperatorToken); Assert.assertTrue(tokens.poll() instanceof IntegerToken); Assert.a... | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void invalidStringsShouldFail() { try { parser.parse("2016/12/25 this is nonsense"); Assert.fail("A DateCalcException should have been thrown (Unable to identify token)"); } catch (DateCalcException dce) { } } | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void testWithAm() { Queue<Token> words = parser.parse("12:37am"); Assert.assertEquals(words.size(), 1); Assert.assertTrue(words.poll() instanceof TimeToken); } | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void testTimeDiffWithAm() { Queue<Token> words = parser.parse("12:37am-5:00am"); Assert.assertEquals(words.size(), 3); Assert.assertTrue(words.poll() instanceof TimeToken); Assert.assertTrue(words.poll() instanceof OperatorToken); Assert.assertTrue(words.poll() instanceof TimeToken); } | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test(expectedExceptions = {DateCalcException.class}) public void shouldRejectBadTimes() { parser.parse("22:89"); } | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void paddedWithSpaces() { parser.parse(" now + 15 weeks "); } | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void testDateMath() { final String expression = "today + 2 weeks 3 days"; DateCalculatorResult result = dc.calculate(expression); Assert.assertNotNull(result.getDate().get(), "'" + expression + "' should have returned a result."); } | public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.peek() instanceof T... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... |
@Test public void testDateDiff() { final String expression = "2016/07/04 - 1776/07/04"; DateCalculatorResult result = dc.calculate(expression); Assert.assertEquals(result.getPeriod().get(), Period.of(240,0,0), "'" + expression + "' should..."); } | public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.peek() instanceof T... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... |
@Test public void timeMath() { final String expression = "12:37 + 42 m"; DateCalculatorResult result = dc.calculate(expression); Assert.assertEquals(result.getTime().get(), LocalTime.parse("13:19")); } | public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.peek() instanceof T... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... |
@Test public void timeDiff() { final String expression = "12:37 - 7:15"; DateCalculatorResult result = dc.calculate(expression); Assert.assertEquals(result.getDuration().get().toHoursPart(), 5); Assert.assertEquals(result.getDuration().get().toMinutesPart(), 22); } | public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.peek() instanceof T... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... | DateCalculator { public DateCalculatorResult calculate(String text) { final DateCalcExpressionParser parser = new DateCalcExpressionParser(); final Queue<Token> tokens = parser.parse(text); try { if (!tokens.isEmpty()) { if (tokens.peek() instanceof DateToken) { return handleDateExpression(tokens); } else if (tokens.pe... |
@Test public void todayWithSpaces() { Queue<Token> words = parser.parse("today + 2 weeks"); Assert.assertTrue(words.poll() instanceof DateToken); Assert.assertTrue(words.poll() instanceof OperatorToken); Assert.assertTrue(words.poll() instanceof IntegerToken); Assert.assertTrue(words.poll() instanceof UnitOfMeasureToke... | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void todayWithoutSpaces() { Queue<Token> words = parser.parse("today+2w"); Assert.assertTrue(words.poll() instanceof DateToken); Assert.assertTrue(words.poll() instanceof OperatorToken); Assert.assertTrue(words.poll() instanceof IntegerToken); Assert.assertTrue(words.poll() instanceof UnitOfMeasureToken); ... | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void nowWithSpacesAndTime() { Queue<Token> words = parser.parse("now + 03:04"); Assert.assertTrue(words.poll() instanceof TimeToken); Assert.assertTrue(words.poll() instanceof OperatorToken); Assert.assertTrue(words.poll() instanceof TimeToken); } | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void nowWithSpacesAndUnitOfMeasure() { Queue<Token> tokens = parser.parse("now + 3h4m"); Assert.assertEquals(tokens.size(), 6); Assert.assertTrue(tokens.poll() instanceof TimeToken); Assert.assertTrue(tokens.poll() instanceof OperatorToken); Assert.assertTrue(tokens.poll() instanceof IntegerToken); Assert.... | public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound = true; String match = mat... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... | DateCalcExpressionParser { public Queue<Token> parse(String text) { final Queue<Token> tokens = new ArrayDeque<>(); if (text != null) { text = text.trim(); if (!text.isEmpty()) { boolean matchFound = false; for (InfoWrapper iw : infos) { final Matcher matcher = iw.pattern.matcher(text); if (matcher.find()) { matchFound... |
@Test public void booksAndAuthors() { Author author = new Author(); author.name = "Greg L. Turnquist"; author = authorRepo.save(author); Book book = new Book(); book.title = "Spring Boot"; book.addAuthor(author); bookRepo.save(book); bookRepo.deleteAll(); assertThat(authorRepo.count()).isEqualTo(1); } | public void addAuthor(Author author) { authors.add(createAuthorRef(author)); } | Book { public void addAuthor(Author author) { authors.add(createAuthorRef(author)); } } | Book { public void addAuthor(Author author) { authors.add(createAuthorRef(author)); } } | Book { public void addAuthor(Author author) { authors.add(createAuthorRef(author)); } void addAuthor(Author author); } | Book { public void addAuthor(Author author) { authors.add(createAuthorRef(author)); } void addAuthor(Author author); } |
@Test( expected = AssertionError.class ) public void testDecode_fail_type() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.INTEGER.ref().resolve( scope ); try( AbstractBerReader reader = mock( DefaultBerReader.class ) ) { Tag tag = ( (TagEncoding)type.getEncoding( Enc... | @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.ENUMERATED; return context.getType().optimize( context.getScope(), IntegerBerDecoder.readInteger( context.getReader(), context.getLength() ) ); } | EnumeratedBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.ENUMERATED; return context.getType().optimize( context.getScope(), IntegerBerDecoder.readInteger( context.getReader(), context.g... | EnumeratedBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.ENUMERATED; return context.getType().optimize( context.getScope(), IntegerBerDecoder.readInteger( context.getReader(), context.g... | EnumeratedBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.ENUMERATED; return context.getType().optimize( context.getScope(), IntegerBerDecoder.readInteger( context.getReader(), context.g... | EnumeratedBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) throws IOException, Asn1Exception { assert context.getType().getFamily() == Family.ENUMERATED; return context.getType().optimize( context.getScope(), IntegerBerDecoder.readInteger( context.getReader(), context.g... |
@Test( expected = ResolutionException.class ) public void testParserOptionalFail() throws Exception { ModuleImpl module = ModuleImpl.newDummy( new ModuleSet() ); ClassTypeImpl classType = new ClassTypeImpl(); classType.setSyntaxList( Arrays.asList( "&Type", "IDENTIFIED", "BY", "&id", "[", "CONSTRAINED", "BY", "&TypeCon... | @Override public Value resolve( Scope scope ) throws ResolutionException { Type type = scope.getTypeOrDie(); while( type != null && !( type instanceof ClassType ) ) type = type.hasSibling() ? type.getSibling() : null; if( type == null ) throw new ResolutionException( "Unable to find ClassType" ); Module module = scope.... | AbstractSyntaxObjectRef implements Ref<Value> { @Override public Value resolve( Scope scope ) throws ResolutionException { Type type = scope.getTypeOrDie(); while( type != null && !( type instanceof ClassType ) ) type = type.hasSibling() ? type.getSibling() : null; if( type == null ) throw new ResolutionException( "Una... | AbstractSyntaxObjectRef implements Ref<Value> { @Override public Value resolve( Scope scope ) throws ResolutionException { Type type = scope.getTypeOrDie(); while( type != null && !( type instanceof ClassType ) ) type = type.hasSibling() ? type.getSibling() : null; if( type == null ) throw new ResolutionException( "Una... | AbstractSyntaxObjectRef implements Ref<Value> { @Override public Value resolve( Scope scope ) throws ResolutionException { Type type = scope.getTypeOrDie(); while( type != null && !( type instanceof ClassType ) ) type = type.hasSibling() ? type.getSibling() : null; if( type == null ) throw new ResolutionException( "Una... | AbstractSyntaxObjectRef implements Ref<Value> { @Override public Value resolve( Scope scope ) throws ResolutionException { Type type = scope.getTypeOrDie(); while( type != null && !( type instanceof ClassType ) ) type = type.hasSibling() ? type.getSibling() : null; if( type == null ) throw new ResolutionException( "Una... |
@Test( expected = ResolutionException.class ) public void testParserOptionalFailValue() throws Exception { ModuleImpl module = ModuleImpl.newDummy( new ModuleSet() ); ClassTypeImpl classType = new ClassTypeImpl(); classType.setSyntaxList( Arrays.asList( "&Type", "IDENTIFIED", "BY", "&id", "[", "CONSTRAINED", "BY", "&Ty... | @Override public Value resolve( Scope scope ) throws ResolutionException { Type type = scope.getTypeOrDie(); while( type != null && !( type instanceof ClassType ) ) type = type.hasSibling() ? type.getSibling() : null; if( type == null ) throw new ResolutionException( "Unable to find ClassType" ); Module module = scope.... | AbstractSyntaxObjectRef implements Ref<Value> { @Override public Value resolve( Scope scope ) throws ResolutionException { Type type = scope.getTypeOrDie(); while( type != null && !( type instanceof ClassType ) ) type = type.hasSibling() ? type.getSibling() : null; if( type == null ) throw new ResolutionException( "Una... | AbstractSyntaxObjectRef implements Ref<Value> { @Override public Value resolve( Scope scope ) throws ResolutionException { Type type = scope.getTypeOrDie(); while( type != null && !( type instanceof ClassType ) ) type = type.hasSibling() ? type.getSibling() : null; if( type == null ) throw new ResolutionException( "Una... | AbstractSyntaxObjectRef implements Ref<Value> { @Override public Value resolve( Scope scope ) throws ResolutionException { Type type = scope.getTypeOrDie(); while( type != null && !( type instanceof ClassType ) ) type = type.hasSibling() ? type.getSibling() : null; if( type == null ) throw new ResolutionException( "Una... | AbstractSyntaxObjectRef implements Ref<Value> { @Override public Value resolve( Scope scope ) throws ResolutionException { Type type = scope.getTypeOrDie(); while( type != null && !( type instanceof ClassType ) ) type = type.hasSibling() ? type.getSibling() : null; if( type == null ) throw new ResolutionException( "Una... |
@Test public void doTest() throws Exception { Asn1Factory factory = new DefaultAsn1Factory(); Module module = factory.types().dummyModule(); DefinedType type = factory.types().define( "MyInt", factory.types().builtin( "INTEGER" ), null ); module.validate(); ConstraintTemplate e = factory.constraints().elements( constra... | public Elements( @NotNull Constraint unions, @Nullable Constraint exclusion ) { this.unions = unions; this.exclusion = exclusion; } | Elements implements Constraint { public Elements( @NotNull Constraint unions, @Nullable Constraint exclusion ) { this.unions = unions; this.exclusion = exclusion; } } | Elements implements Constraint { public Elements( @NotNull Constraint unions, @Nullable Constraint exclusion ) { this.unions = unions; this.exclusion = exclusion; } Elements( @NotNull Constraint unions, @Nullable Constraint exclusion ); } | Elements implements Constraint { public Elements( @NotNull Constraint unions, @Nullable Constraint exclusion ) { this.unions = unions; this.exclusion = exclusion; } Elements( @NotNull Constraint unions, @Nullable Constraint exclusion ); @Override void check( Scope scope, Ref<Value> valueRef ); @NotNull @Override Constr... | Elements implements Constraint { public Elements( @NotNull Constraint unions, @Nullable Constraint exclusion ) { this.unions = unions; this.exclusion = exclusion; } Elements( @NotNull Constraint unions, @Nullable Constraint exclusion ); @Override void check( Scope scope, Ref<Value> valueRef ); @NotNull @Override Constr... |
@Test public void doTest() { Asn1Factory factory = new DefaultAsn1Factory(); Module module = factory.types().dummyModule(); DefinedType type = factory.types().define( "MyInt", factory.types().builtin( "INTEGER" ), null ); ConstraintTemplate specs = unions == null ? factory.constraints().elementSetSpec( exclusion ) : fa... | public ElementSetSpec( List<Constraint> unions ) { this.unions = new ArrayList<>( unions ); } | ElementSetSpec implements Constraint { public ElementSetSpec( List<Constraint> unions ) { this.unions = new ArrayList<>( unions ); } } | ElementSetSpec implements Constraint { public ElementSetSpec( List<Constraint> unions ) { this.unions = new ArrayList<>( unions ); } ElementSetSpec( List<Constraint> unions ); } | ElementSetSpec implements Constraint { public ElementSetSpec( List<Constraint> unions ) { this.unions = new ArrayList<>( unions ); } ElementSetSpec( List<Constraint> unions ); @Override void check( Scope scope, Ref<Value> valueRef ); @NotNull @Override Value getMinimumValue( @NotNull Scope scope ); @NotNull @Override V... | ElementSetSpec implements Constraint { public ElementSetSpec( List<Constraint> unions ) { this.unions = new ArrayList<>( unions ); } ElementSetSpec( List<Constraint> unions ); @Override void check( Scope scope, Ref<Value> valueRef ); @NotNull @Override Value getMinimumValue( @NotNull Scope scope ); @NotNull @Override V... |
@Test public void testUTCParse() throws Exception { Instant now = Instant.now(); LocalDateTime ldt = LocalDateTime.ofInstant( now, ZoneId.of( "GMT" ) ); now = ldt.withNano( 0 ).toInstant( ZoneOffset.UTC ); DateTimeFormatter formatter = DateTimeFormatter.ofPattern( "yyMMddHHmmss" ).withZone( ZoneId.of( "GMT" ) ); String... | public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } } | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } private TimeUtils(); } | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAccessor instant, String format, bo... | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAccessor instant, String format, bo... |
@Test public void testUTCParseMinutes() throws Exception { Instant now = Instant.now(); LocalDateTime ldt = LocalDateTime.ofInstant( now, ZoneId.of( "GMT" ) ); now = ldt.withSecond( 0 ).withNano( 0 ).toInstant( ZoneOffset.UTC ); DateTimeFormatter formatter = DateTimeFormatter.ofPattern( "yyMMddHHmm" ).withZone( ZoneId.... | public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } } | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } private TimeUtils(); } | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAccessor instant, String format, bo... | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAccessor instant, String format, bo... |
@Test public void testUTCParseCustomTz() throws Exception { Instant now = Instant.now(); LocalDateTime ldt = LocalDateTime.ofInstant( now, ZoneId.of( "GMT" ) ); now = ldt.withNano( 0 ).toInstant( ZoneOffset.ofHours( 4 ) ); DateTimeFormatter formatter = DateTimeFormatter.ofPattern( "yyMMddHHmmssZ" ).withZone( ZoneId.sys... | public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } } | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } private TimeUtils(); } | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAccessor instant, String format, bo... | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAccessor instant, String format, bo... |
@Test public void testUTCParseMinutesCustomTz() throws Exception { Instant now = Instant.now(); LocalDateTime ldt = LocalDateTime.ofInstant( now, ZoneId.of( "GMT" ) ); now = ldt.withSecond( 0 ).withNano( 0 ).toInstant( ZoneOffset.ofHours( 4 ) ); DateTimeFormatter formatter = DateTimeFormatter.ofPattern( "yyMMddHHmmZ" )... | public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } } | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } private TimeUtils(); } | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAccessor instant, String format, bo... | TimeUtils { public static Instant parseUTCTime( String value ) { if( !UTCParser.isValid( value ) ) throw new IllegalArgumentException( "Not an UTCTime string: " + value ); return new UTCParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAccessor instant, String format, bo... |
@Test public void testGeneralizedParse() throws Exception { Instant now = Instant.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern( "yyyyMMddHHmmss.SSS" ).withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( now ) + 'Z'; Instant instant = TimeUtils.parseGeneralizedTime( result ); Assert.ass... | public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAcc... | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAcc... |
@Test public void testGeneralizedParseNoZ() throws Exception { Instant now = Instant.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern( "yyyyMMddHHmmss.SSS" ).withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( now ); Instant instant = TimeUtils.parseGeneralizedTime( result ); Assert.assert... | public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAcc... | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAcc... |
@Test( expected = AssertionError.class ) public void testDecode_fail_length() throws Exception { Scope scope = CoreModule.getInstance().createScope(); Type type = UniversalType.NULL.ref().resolve( scope ); try( AbstractBerReader reader = mock( DefaultBerReader.class ) ) { Tag tag = ( (TagEncoding)type.getEncoding( Enco... | @Override public Value decode( @NotNull ReaderContext context ) { assert context.getType().getFamily() == Family.NULL; assert context.getLength() == 0; return NullValue.INSTANCE; } | NullBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) { assert context.getType().getFamily() == Family.NULL; assert context.getLength() == 0; return NullValue.INSTANCE; } } | NullBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) { assert context.getType().getFamily() == Family.NULL; assert context.getLength() == 0; return NullValue.INSTANCE; } } | NullBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) { assert context.getType().getFamily() == Family.NULL; assert context.getLength() == 0; return NullValue.INSTANCE; } @Override Value decode( @NotNull ReaderContext context ); } | NullBerDecoder implements BerDecoder { @Override public Value decode( @NotNull ReaderContext context ) { assert context.getType().getFamily() == Family.NULL; assert context.getLength() == 0; return NullValue.INSTANCE; } @Override Value decode( @NotNull ReaderContext context ); } |
@Test public void testGeneralizedParseNoFracture() throws Exception { Instant now = Instant.now(); LocalDateTime ldt = LocalDateTime.ofInstant( now, ZoneId.of( "GMT" ) ); now = ldt.withNano( 0 ).toInstant( ZoneOffset.UTC ); DateTimeFormatter formatter = DateTimeFormatter.ofPattern( "yyyyMMddHHmmss" ).withZone( ZoneId.o... | public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAcc... | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAcc... |
@Test public void testGeneralizedParseNoFractureNoSeconds() throws Exception { Instant now = Instant.now(); LocalDateTime ldt = LocalDateTime.ofInstant( now, ZoneId.of( "GMT" ) ); now = ldt.withSecond( 0 ).withNano( 0 ).toInstant( ZoneOffset.UTC ); DateTimeFormatter formatter = DateTimeFormatter.ofPattern( "yyyyMMddHHm... | public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAcc... | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAcc... |
@Test public void testGeneralizedParseNoFractureNoZ() throws Exception { Instant now = Instant.now(); LocalDateTime ldt = LocalDateTime.ofInstant( now, ZoneId.of( "GMT" ) ); now = ldt.withNano( 0 ).toInstant( ZoneOffset.UTC ); DateTimeFormatter formatter = DateTimeFormatter.ofPattern( "yyyyMMddHHmmss" ).withZone( ZoneI... | public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAcc... | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAcc... |
@Test public void testGeneralizedParseNoMinutesWithFracture() throws Exception { Instant now = Instant.now(); LocalDateTime ldt = LocalDateTime.ofInstant( now, ZoneId.of( "GMT" ) ); ldt = ldt.withMinute( 59 ).withSecond( 52 ).withNano( 800000000 ); now = ldt.toInstant( ZoneOffset.UTC ); DateTimeFormatter formatter = Da... | public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAcc... | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAcc... |
@Test public void testGeneralizedParseCustomTz() throws Exception { Instant now = Instant.now(); LocalDateTime ldt = LocalDateTime.ofInstant( now, ZoneId.of( "GMT" ) ); now = ldt.withNano( 0 ).toInstant( ZoneOffset.UTC ); DateTimeFormatter formatter = DateTimeFormatter.ofPattern( "yyyyMMddHHmmssZ" ).withZone( ZoneId.sy... | public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); } | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAcc... | TimeUtils { public static Instant parseGeneralizedTime( String value ) { if( !GeneralizedParser.isValid( value ) ) throw new IllegalArgumentException( "Not an GeneralizedTime string: " + value ); return new GeneralizedParser( value ).asInstant(); } private TimeUtils(); @NotNull static String formatInstant( TemporalAcc... |
@Test public void testFormatInstant000() { Instant now = Instant.now(); LocalDateTime ldt = LocalDateTime.ofInstant( now, ZoneId.of( "GMT" ) ); ldt = ldt.withYear( 2000 ).withMonth( 1 ).withDayOfMonth( 1 ).withHour( 1 ).withMinute( 0 ).withSecond( 0 ).withNano( 0 ); now = ldt.toInstant( ZoneOffset.UTC ); String result ... | @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ".000" ) ) r... | TimeUtils { @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ... | TimeUtils { @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ... | TimeUtils { @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ... | TimeUtils { @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ... |
@Test public void testFormatInstant00() { Instant now = Instant.now(); LocalDateTime ldt = LocalDateTime.ofInstant( now, ZoneId.of( "GMT" ) ); ldt = ldt.withYear( 2000 ).withMonth( 1 ).withDayOfMonth( 1 ).withHour( 1 ).withMinute( 0 ).withSecond( 0 ) .withNano( 880000000 ); now = ldt.toInstant( ZoneOffset.UTC ); String... | @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ".000" ) ) r... | TimeUtils { @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ... | TimeUtils { @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ... | TimeUtils { @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ... | TimeUtils { @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ... |
@Test public void testFormatInstant0() { Instant now = Instant.now(); LocalDateTime ldt = LocalDateTime.ofInstant( now, ZoneId.of( "GMT" ) ); ldt = ldt.withYear( 2000 ).withMonth( 1 ).withDayOfMonth( 1 ).withHour( 1 ).withMinute( 0 ).withSecond( 0 ) .withNano( 800000000 ); now = ldt.toInstant( ZoneOffset.UTC ); String ... | @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ".000" ) ) r... | TimeUtils { @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ... | TimeUtils { @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ... | TimeUtils { @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ... | TimeUtils { @NotNull public static String formatInstant( TemporalAccessor instant, String format, boolean optimize ) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern( format ) .withZone( ZoneId.of( "GMT" ) ); String result = formatter.format( instant ); if( result.indexOf( '.' ) > 0 ) { if( result.endsWith( ... |
@Test public void testValues() throws Exception { assertEquals( "Not equal", "1.E-1", NRxUtils.toCanonicalNR3( "0.01E1" ) ); assertEquals( "Not equal", "+0.E1", NRxUtils.toCanonicalNR3( "0.00000E1" ) ); assertEquals( "Not equal", "12312.E+0", NRxUtils.toCanonicalNR3( "12312" ) ); assertEquals( "Not equal", "12312123121... | public static String toCanonicalNR3( String value ) { if( "-Infinity".equals( value ) || "Infinity".equals( value ) || "NaN".equals( value ) ) return value; if( !FORMAT_PATTERN.matcher( value ).matches() ) throw new IllegalArgumentException(); value = value.toUpperCase(); String mantisStr; String exponentStr; int expIn... | NRxUtils { public static String toCanonicalNR3( String value ) { if( "-Infinity".equals( value ) || "Infinity".equals( value ) || "NaN".equals( value ) ) return value; if( !FORMAT_PATTERN.matcher( value ).matches() ) throw new IllegalArgumentException(); value = value.toUpperCase(); String mantisStr; String exponentStr... | NRxUtils { public static String toCanonicalNR3( String value ) { if( "-Infinity".equals( value ) || "Infinity".equals( value ) || "NaN".equals( value ) ) return value; if( !FORMAT_PATTERN.matcher( value ).matches() ) throw new IllegalArgumentException(); value = value.toUpperCase(); String mantisStr; String exponentStr... | NRxUtils { public static String toCanonicalNR3( String value ) { if( "-Infinity".equals( value ) || "Infinity".equals( value ) || "NaN".equals( value ) ) return value; if( !FORMAT_PATTERN.matcher( value ).matches() ) throw new IllegalArgumentException(); value = value.toUpperCase(); String mantisStr; String exponentStr... | NRxUtils { public static String toCanonicalNR3( String value ) { if( "-Infinity".equals( value ) || "Infinity".equals( value ) || "NaN".equals( value ) ) return value; if( !FORMAT_PATTERN.matcher( value ).matches() ) throw new IllegalArgumentException(); value = value.toUpperCase(); String mantisStr; String exponentStr... |
@Test( expected = IllegalArgumentException.class ) public void testNotTypeRef() { RefUtils.assertTypeRef( "a" ); } | public static void assertTypeRef( String name ) { if( !isTypeRef( name ) ) throw new IllegalArgumentException( "Not a type reference: " + name ); } | RefUtils { public static void assertTypeRef( String name ) { if( !isTypeRef( name ) ) throw new IllegalArgumentException( "Not a type reference: " + name ); } } | RefUtils { public static void assertTypeRef( String name ) { if( !isTypeRef( name ) ) throw new IllegalArgumentException( "Not a type reference: " + name ); } private RefUtils(); } | RefUtils { public static void assertTypeRef( String name ) { if( !isTypeRef( name ) ) throw new IllegalArgumentException( "Not a type reference: " + name ); } private RefUtils(); static void assertTypeRef( String name ); static boolean isSameAsDefaultValue( Scope scope, ComponentType component, Value resolve ); static... | RefUtils { public static void assertTypeRef( String name ) { if( !isTypeRef( name ) ) throw new IllegalArgumentException( "Not a type reference: " + name ); } private RefUtils(); static void assertTypeRef( String name ); static boolean isSameAsDefaultValue( Scope scope, ComponentType component, Value resolve ); static... |
@Test public void writeHugeReal() throws Exception { Asn1Factory factory = new DefaultAsn1Factory(); Module module = factory.types().dummyModule(); Scope scope = module.createScope(); ConstraintTemplate constraintTemplate = factory.constraints().valueRange( new RealValueFloat( 0.0f ), false, null, false ); Type tagged ... | @SuppressWarnings( "NumericCastThatLosesPrecision" ) @Override public byte read() throws IOException { int read = is.read(); if( read != -1 ) position++; return (byte)read; } | DefaultBerReader extends AbstractBerReader { @SuppressWarnings( "NumericCastThatLosesPrecision" ) @Override public byte read() throws IOException { int read = is.read(); if( read != -1 ) position++; return (byte)read; } } | DefaultBerReader extends AbstractBerReader { @SuppressWarnings( "NumericCastThatLosesPrecision" ) @Override public byte read() throws IOException { int read = is.read(); if( read != -1 ) position++; return (byte)read; } DefaultBerReader( InputStream is, ValueFactory valueFactory ); } | DefaultBerReader extends AbstractBerReader { @SuppressWarnings( "NumericCastThatLosesPrecision" ) @Override public byte read() throws IOException { int read = is.read(); if( read != -1 ) position++; return (byte)read; } DefaultBerReader( InputStream is, ValueFactory valueFactory ); @Override int position(); @Override v... | DefaultBerReader extends AbstractBerReader { @SuppressWarnings( "NumericCastThatLosesPrecision" ) @Override public byte read() throws IOException { int read = is.read(); if( read != -1 ) position++; return (byte)read; } DefaultBerReader( InputStream is, ValueFactory valueFactory ); @Override int position(); @Override v... |
@Test( expected = IllegalArgumentException.class ) public void testNotValueRef() { RefUtils.assertValueRef( "A" ); } | public static void assertValueRef( String name ) { if( !isValueRef( name ) ) throw new IllegalArgumentException( "Not a value reference: " + name ); } | RefUtils { public static void assertValueRef( String name ) { if( !isValueRef( name ) ) throw new IllegalArgumentException( "Not a value reference: " + name ); } } | RefUtils { public static void assertValueRef( String name ) { if( !isValueRef( name ) ) throw new IllegalArgumentException( "Not a value reference: " + name ); } private RefUtils(); } | RefUtils { public static void assertValueRef( String name ) { if( !isValueRef( name ) ) throw new IllegalArgumentException( "Not a value reference: " + name ); } private RefUtils(); static void assertTypeRef( String name ); static boolean isSameAsDefaultValue( Scope scope, ComponentType component, Value resolve ); sta... | RefUtils { public static void assertValueRef( String name ) { if( !isValueRef( name ) ) throw new IllegalArgumentException( "Not a value reference: " + name ); } private RefUtils(); static void assertTypeRef( String name ); static boolean isSameAsDefaultValue( Scope scope, ComponentType component, Value resolve ); sta... |
@Test public void testSameAsDefault() throws Exception { MyIntegerValue value = new MyIntegerValue(); assertTrue( "Must be true", RefUtils.isSameAsDefaultValue( new MyScope(), new MyAbstractComponentType( value ), value ) ); } | public static boolean isSameAsDefaultValue( Scope scope, ComponentType component, Value resolve ) throws ResolutionException { if( component.getDefaultValue() == null ) return false; resolve = toBasicValue( scope, resolve ); Value value = toBasicValue( scope, component.getDefaultValue() ); return resolve.isEqualTo( val... | RefUtils { public static boolean isSameAsDefaultValue( Scope scope, ComponentType component, Value resolve ) throws ResolutionException { if( component.getDefaultValue() == null ) return false; resolve = toBasicValue( scope, resolve ); Value value = toBasicValue( scope, component.getDefaultValue() ); return resolve.isE... | RefUtils { public static boolean isSameAsDefaultValue( Scope scope, ComponentType component, Value resolve ) throws ResolutionException { if( component.getDefaultValue() == null ) return false; resolve = toBasicValue( scope, resolve ); Value value = toBasicValue( scope, component.getDefaultValue() ); return resolve.isE... | RefUtils { public static boolean isSameAsDefaultValue( Scope scope, ComponentType component, Value resolve ) throws ResolutionException { if( component.getDefaultValue() == null ) return false; resolve = toBasicValue( scope, resolve ); Value value = toBasicValue( scope, component.getDefaultValue() ); return resolve.isE... | RefUtils { public static boolean isSameAsDefaultValue( Scope scope, ComponentType component, Value resolve ) throws ResolutionException { if( component.getDefaultValue() == null ) return false; resolve = toBasicValue( scope, resolve ); Value value = toBasicValue( scope, component.getDefaultValue() ); return resolve.isE... |
@Test public void testConversion() throws Exception { assertEquals( "Is not equal", "0A", HexUtils.toHexString( new byte[]{0x0A} ) ); assertEquals( "Is not equal", "0A0A", HexUtils.toHexString( new byte[]{0x0A, 0x0A} ) ); assertEquals( "Is not equal", "", HexUtils.toHexString( new byte[]{} ) ); } | @SuppressWarnings( "MagicNumber" ) public static String toHexString( byte[] array ) { if( ArrayUtils.isEmpty( array ) ) return ""; StringBuilder sb = new StringBuilder(); for( byte value : array ) { if( ( value & 0xF0 ) == 0 ) sb.append( '0' ); sb.append( Integer.toHexString( value & 0xFF ).toUpperCase() ); } return sb... | HexUtils { @SuppressWarnings( "MagicNumber" ) public static String toHexString( byte[] array ) { if( ArrayUtils.isEmpty( array ) ) return ""; StringBuilder sb = new StringBuilder(); for( byte value : array ) { if( ( value & 0xF0 ) == 0 ) sb.append( '0' ); sb.append( Integer.toHexString( value & 0xFF ).toUpperCase() ); ... | HexUtils { @SuppressWarnings( "MagicNumber" ) public static String toHexString( byte[] array ) { if( ArrayUtils.isEmpty( array ) ) return ""; StringBuilder sb = new StringBuilder(); for( byte value : array ) { if( ( value & 0xF0 ) == 0 ) sb.append( '0' ); sb.append( Integer.toHexString( value & 0xFF ).toUpperCase() ); ... | HexUtils { @SuppressWarnings( "MagicNumber" ) public static String toHexString( byte[] array ) { if( ArrayUtils.isEmpty( array ) ) return ""; StringBuilder sb = new StringBuilder(); for( byte value : array ) { if( ( value & 0xF0 ) == 0 ) sb.append( '0' ); sb.append( Integer.toHexString( value & 0xFF ).toUpperCase() ); ... | HexUtils { @SuppressWarnings( "MagicNumber" ) public static String toHexString( byte[] array ) { if( ArrayUtils.isEmpty( array ) ) return ""; StringBuilder sb = new StringBuilder(); for( byte value : array ) { if( ( value & 0xF0 ) == 0 ) sb.append( '0' ); sb.append( Integer.toHexString( value & 0xFF ).toUpperCase() ); ... |
@Test public void testConversion() throws Exception { IntegerValue value = new MyIntegerValue(); MyScope scope = new MyScope(); MyNamedValue namedValue = new MyNamedValue( (IntegerValue)RefUtils.toBasicValue( scope, value ) ); String result = CollectionUtils.convertToBString( Collections.singletonList( namedValue ), 4 ... | @NotNull public static String convertToBString( Iterable<? extends Ref<Value>> valueList, int desiredSize ) { Collection<Long> values = new HashSet<>(); Long maxValue = 0L; for( Ref<Value> valueRef : valueList ) { NamedValue value = (NamedValue)valueRef; if( value.getReferenceKind() != Kind.INTEGER || !value.toIntegerV... | CollectionUtils { @NotNull public static String convertToBString( Iterable<? extends Ref<Value>> valueList, int desiredSize ) { Collection<Long> values = new HashSet<>(); Long maxValue = 0L; for( Ref<Value> valueRef : valueList ) { NamedValue value = (NamedValue)valueRef; if( value.getReferenceKind() != Kind.INTEGER ||... | CollectionUtils { @NotNull public static String convertToBString( Iterable<? extends Ref<Value>> valueList, int desiredSize ) { Collection<Long> values = new HashSet<>(); Long maxValue = 0L; for( Ref<Value> valueRef : valueList ) { NamedValue value = (NamedValue)valueRef; if( value.getReferenceKind() != Kind.INTEGER ||... | CollectionUtils { @NotNull public static String convertToBString( Iterable<? extends Ref<Value>> valueList, int desiredSize ) { Collection<Long> values = new HashSet<>(); Long maxValue = 0L; for( Ref<Value> valueRef : valueList ) { NamedValue value = (NamedValue)valueRef; if( value.getReferenceKind() != Kind.INTEGER ||... | CollectionUtils { @NotNull public static String convertToBString( Iterable<? extends Ref<Value>> valueList, int desiredSize ) { Collection<Long> values = new HashSet<>(); Long maxValue = 0L; for( Ref<Value> valueRef : valueList ) { NamedValue value = (NamedValue)valueRef; if( value.getReferenceKind() != Kind.INTEGER ||... |
@Test( expected = IllegalStateException.class ) public void testIllegalRef() throws Exception { TemplateParameter parameter = new TemplateParameter( 0, scope -> { throw new UnsupportedOperationException(); }, null ); parameter.getName(); fail( "Must fail" ); } | public String getName() { if( reference instanceof TypeNameRef ) return ( (TypeNameRef)reference ).getName(); if( reference instanceof ValueNameRef ) return ( (ValueNameRef)reference ).getName(); throw new IllegalStateException(); } | TemplateParameter implements Comparable<TemplateParameter> { public String getName() { if( reference instanceof TypeNameRef ) return ( (TypeNameRef)reference ).getName(); if( reference instanceof ValueNameRef ) return ( (ValueNameRef)reference ).getName(); throw new IllegalStateException(); } } | TemplateParameter implements Comparable<TemplateParameter> { public String getName() { if( reference instanceof TypeNameRef ) return ( (TypeNameRef)reference ).getName(); if( reference instanceof ValueNameRef ) return ( (ValueNameRef)reference ).getName(); throw new IllegalStateException(); } TemplateParameter( int ind... | TemplateParameter implements Comparable<TemplateParameter> { public String getName() { if( reference instanceof TypeNameRef ) return ( (TypeNameRef)reference ).getName(); if( reference instanceof ValueNameRef ) return ( (ValueNameRef)reference ).getName(); throw new IllegalStateException(); } TemplateParameter( int ind... | TemplateParameter implements Comparable<TemplateParameter> { public String getName() { if( reference instanceof TypeNameRef ) return ( (TypeNameRef)reference ).getName(); if( reference instanceof ValueNameRef ) return ( (ValueNameRef)reference ).getName(); throw new IllegalStateException(); } TemplateParameter( int ind... |
@Test public void testTemplate() throws Exception { Template template = new Template(); assertEquals( "Parameter count must be 0", 0, template.getParameterCount() ); template.addParameter( new TemplateParameter( 0, new TypeNameRef( "A" ), null ) ); assertEquals( "Parameter count must be 1", 1, template.getParameterCoun... | public Template() { this( false ); } | Template { public Template() { this( false ); } } | Template { public Template() { this( false ); } Template(); Template( boolean instance ); } | Template { public Template() { this( false ); } Template(); Template( boolean instance ); void addParameter( TemplateParameter parameter ); @Nullable TemplateParameter getParameter( @NotNull String name ); @NotNull TemplateParameter getParameter( int index ); int getParameterCount(); boolean isInstance(); } | Template { public Template() { this( false ); } Template(); Template( boolean instance ); void addParameter( TemplateParameter parameter ); @Nullable TemplateParameter getParameter( @NotNull String name ); @NotNull TemplateParameter getParameter( int index ); int getParameterCount(); boolean isInstance(); } |
@Test( expected = IllegalArgumentException.class ) public void testIllegalIndexGet() throws Exception { Template template = new Template(); template.getParameter( 1 ); fail( "Must fail" ); } | @Nullable public TemplateParameter getParameter( @NotNull String name ) { return parameterMap.get( name ); } | Template { @Nullable public TemplateParameter getParameter( @NotNull String name ) { return parameterMap.get( name ); } } | Template { @Nullable public TemplateParameter getParameter( @NotNull String name ) { return parameterMap.get( name ); } Template(); Template( boolean instance ); } | Template { @Nullable public TemplateParameter getParameter( @NotNull String name ) { return parameterMap.get( name ); } Template(); Template( boolean instance ); void addParameter( TemplateParameter parameter ); @Nullable TemplateParameter getParameter( @NotNull String name ); @NotNull TemplateParameter getParameter( ... | Template { @Nullable public TemplateParameter getParameter( @NotNull String name ) { return parameterMap.get( name ); } Template(); Template( boolean instance ); void addParameter( TemplateParameter parameter ); @Nullable TemplateParameter getParameter( @NotNull String name ); @NotNull TemplateParameter getParameter( ... |
@Test( expected = IllegalArgumentException.class ) public void testDuplicateFail() throws Exception { mapperFactory.mapType( Values.class, null ); fail( "Must fail" ); } | @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } } | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... |
@Test( expected = IllegalArgumentException.class ) public void testUnsupportedType() throws Exception { mapperFactory.mapType( Integer.class, null ); fail( "Must fail!" ); } | @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } } | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... | EnumTypeMapperFactory implements TypeMapperFactory { @SuppressWarnings( "unchecked" ) @Override public TypeMapper mapType( Type type, TypeMetadata metadata ) { if( !isSupportedFor( type ) ) throw new IllegalArgumentException( "Only enum types allowed" ); return mapEnum( (Class<Enum<?>>)type ); } EnumTypeMapperFactory( ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.