我有一个递归查询,它确实扩展了这个Java猴子SQL知识的限制.现在它终于凌晨1点半了,现在可能是时候开始寻求帮助了.这是谷歌失败的少数几次之一.
表格如下:
Parent_ID CHILD_ID QTY
25 26 1
25 27 2
26 28 1
26 29 1
26 30 2
27 31 1
27 32 1
27 33 2
Run Code Online (Sandbox Code Playgroud)
我正在尝试获得以下结果,其中父项列出了下面的每个子项.注意qty的级联也是如此.
BASE PARENT_ID CHILD_ID QTY
25 25 26 1
25 25 27 2
25 26 28 1
25 26 29 1
25 26 30 1
25 27 31 2
25 27 32 2
25 27 33 4
26 26 28 1
26 26 29 1
26 26 30 2
27 27 …Run Code Online (Sandbox Code Playgroud) 我正在尝试(仍然)学习JMockit的细节.这是JMockit奇怪的另一个例子,我只是没有得到.使用NonStrictExpectations运行测试工作正常.但是,使用MockUp运行却没有.我不知道为什么.有任何想法吗?我正在运行JMockit 1.5.
测试方法:
private List<Foo> getFooList(List<FooStatement> fooStatements){
List<Foo> FooList = new ArrayList<Foo>();
for(FooStatement at: fooStatements){
List<Foo> aList = at.getFoos();
FooList.addAll(aList);
}
return FooList;
}
Run Code Online (Sandbox Code Playgroud)
成功的期望测试
@Test
public void getFooListWithExpectationsTest(
@Mocked final FooStatement mockFooStatement,
@Mocked final Foo mockFoo
){
List<FooStatement> fooStatementList = new ArrayList<>(Arrays.asList(
mockFooStatement,
mockFooStatement
));
new NonStrictExpectations(){{
mockFooStatement.getFoos();
result = new ArrayList<Foo>(Arrays.asList(mockFoo));
}};
List<Foo> fooList = Deencapsulation.invoke(handler, "getFooList", fooStatementList);
Assert.assertTrue(fooList.size() == 2);
}
Run Code Online (Sandbox Code Playgroud)
使用MockUp断言错误(0!= 2)
@Test
public void getFooListWithMockUpTest(
@Mocked final FooStatement mockFooStatement,
@Mocked final Foo mockFoo
){
new …Run Code Online (Sandbox Code Playgroud) 我现在刚刚开始使用R进行单元测试,到目前为止发现它很难进行雪橇测试。我想做的是进入R控制台,键入test()并进行测试,以对我的R包中的所有文件进行测试。
这是我的环境:
sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin15.2.0 (64-bit)
Running under: OS X 10.11.4 (El Capitan)
Run Code Online (Sandbox Code Playgroud)
和目录结构:
math
-- R
------ math.R
------ add.R
------ subtract.R
-- tests
------ testthat.R
------ testthat
---------- test_add.R
---------- test_subtract.R
---------- test_math.R
Run Code Online (Sandbox Code Playgroud)
带有以下相关文件样本:
数学
source('add.R')
source('subtract.R')
doubleAdd <- function(x){
return(add(x,x) + add(x,x))
}
Run Code Online (Sandbox Code Playgroud)
添加
add <- function(a,b){
return(a + b)
}
Run Code Online (Sandbox Code Playgroud)
验证
library(testthat)
library(math)
test_check("math")
Run Code Online (Sandbox Code Playgroud)
test_add.R
context('add tests')
test_that('1 + 1 = 2', {
expect_equal(2, add(1,1))
})
Run Code Online (Sandbox Code Playgroud)
错误:
在R控制台中,我得到以下结果:
library(devtools)
test() …Run Code Online (Sandbox Code Playgroud) 看起来这个问题已经在旧版本的PDFMake中问了很多遍了,但是还没有更新为最新的目录结构。另外,将字体复制到根“ fonts”文件夹中也不太好。
在世界上,如何使用随附的vfs_fonts.js文件在Node.js 上运行服务器版本的PDFMake(“ pdfmake”:“ ^ 0.1.31”)?
在命令行上使用npm进行安装
npm install pdfmake fs --save
Run Code Online (Sandbox Code Playgroud)
使用以下命令启动Node.js应用index.js:
var fonts = {
Roboto: {
normal: 'fonts/Roboto-Regular.ttf',
bold: 'fonts/Roboto-Medium.ttf',
italics: 'fonts/Roboto-Italic.ttf',
bolditalics: 'fonts/Roboto-MediumItalic.ttf'
}
};
var PdfPrinter = require('pdfmake/src/printer');
var printer = new PdfPrinter(fonts);
var dd = {
content: [
'First paragraph',
'Another paragraph'
]
}
var pdfDoc = printer.createPdfKitDocument(dd);
pdfDoc.pipe(fs.createWriteStream('basics.pdf')).on('finish',function(){
//success
});
pdfDoc.end();
Run Code Online (Sandbox Code Playgroud)
击中奔跑:
/usr/local/bin/node index.js
fs.js:640
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: …Run Code Online (Sandbox Code Playgroud) 所有,
使用Keen.io来提取一些分析.我允许用户输入指定开始和结束时间,但我无法找到与"限制"参数等效的内容,例如可以在SQL查询中找到.如果用户指定足够大的范围,则可能导致返回太多数据.
Keen.io有办法撤回第一个"x"记录吗?
bower.json
"keen-js": "^3.4.1",
我正在尝试使用node-postgres (PG)连接到在端口5432上运行的 localhost PostgreSQL 数据库。为此,我设置了ngrok来隧道传输我的请求。
./ngrok tcp 5432
Run Code Online (Sandbox Code Playgroud)
下面的代码在本地运行时有效(即使在使用 ngrok 进行隧道传输时)。当我连接到外部数据库时,它也适用于 lambda - 在我的情况下由 Heroku 托管。
'use strict';
const PG = require('pg');
// These credentials work locally
var credentials = {
user: 'MyUsername',
host: 'tcp://0.tcp.ngrok.io',
database: 'MyDatabase',
password: 'MyPassword',
port: '12829',
ssl: true
};
const pool = new PG.Pool(credentials);
const connectionPromise = function(){
return new Promise(function (resolve, reject) {
pool.connect(function (err, client, done) {
if(err) console.log(err);
err ? reject(err) : resolve({
client: client,
done: …Run Code Online (Sandbox Code Playgroud)