小编Xbr*_*izh的帖子

断言抛出多个异常

谁能告诉我如何使用断言抛出几个异常?

\n\n

例如,这是一个类:

\n\n
 protected void checkViolation(Set<ConstraintViolation<EcritureComptable>> vViolations) throws FunctionalException {\n    if (!vViolations.isEmpty()) {\n        throw new FunctionalException("L\'\xc3\xa9criture comptable ne respecte pas les r\xc3\xa8gles de gestion.",\n                                      new ConstraintViolationException(\n                                          "L\'\xc3\xa9criture comptable ne respecte pas les contraintes de validation",\n                                          vViolations));\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

和我的测试方法:

\n\n
 @Test\nvoid checkViolation(){\n    comptabiliteManager = spy(ComptabiliteManagerImpl.class);\n    when(vViolations.isEmpty()).thenReturn(false);\n\n    assertThrows(  ConstraintViolationException.class, () ->comptabiliteManager.checkViolation(vViolations), "a string should be provided!");\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

我想匹配该方法并完全抛出ConstraintViolationException和FunctionException

\n\n

任何想法?

\n\n

谢谢

\n

java exception mockito juniper

6
推荐指数
1
解决办法
6696
查看次数

如何在postgres中声明区间无穷大?

看来我们目前无法将无穷大作为区间。

在尝试时:
SELECT 'infinity'::interval;`
我们得到

SQL Error [22007]: ERROR: invalid input syntax for type interval: "infinity"
Run Code Online (Sandbox Code Playgroud)

如何指定间隔的最大值?

我尝试比较 2 个无限时间戳

SELECT ('-infinity'::timestamp + '1 day'::INTERVAL)::timestamp without time zone at time zone 'UTC' 
- 'infinity'::timestamp  without time zone at time zone 'UTC';  
Run Code Online (Sandbox Code Playgroud)

但现在得到

SQL Error [22008]: ERROR: cannot subtract infinite timestamps
Run Code Online (Sandbox Code Playgroud)

任何想法?

postgresql infinity

5
推荐指数
1
解决办法
1233
查看次数

如何在日志中分组并计算bash中的每个子组

我想分析一个日志文件。它有几个操作,每个操作包含一组子操作。我想提取按操作分组的子操作数。这在 sql 中很容易,但我在 bash 中陷入困境。

这是该文件的简化版本:

    [21:30:21.538Z #a9a.012 DEBUG -            -   ] c.h.c.w.j.JobTrackingWorkerReporter: Reporting bulk completion: Partition: tenant-xla; Job: ingestion-4759-9-13-41; Tasks: [ingestion-4759-9-13-41.1.43, ingestion-4759-9-13-41.1.44, ingestion-4759-9-13-41.1.41]

otherlogs stuff ...

[21:31:21.538Z #a9a.012 DEBUG -            -   ] c.h.c.w.j.JobTrackingWorkerReporter: Reporting bulk completion: Partition: tenant-xla; Job: ingestion-4757-10-17-4; Tasks: [ingestion-4757-10-17-4.1.2, ingestion-4757-10-17-4.1.1, ingestion-4757-10-17-4.1.3, ingestion-4757-10-17-4.1.4]

otherlogs stuff ...

[21:31:21.690Z #a9a.012 DEBUG -            -   ] c.h.c.w.j.JobTrackingWorkerReporter: Reporting bulk completion: Partition: tenant-xla; Job: ingestion-4757-10-18-3; Tasks: [ingestion-4757-10-18-3.1.137, ingestion-4757-10-18-3.1.139, ingestion-4757-10-18-3.1.138, ingestion-4757-10-18-3.1.140, ingestion-4757-10-18-3.1.136, ingestion-4757-10-18-3.1.141]
Run Code Online (Sandbox Code Playgroud)

每个操作都是点之前的部分,其余部分属于任何子操作。

我正在寻找类似以下的结果,例如,我可以将其存储在文件中:

operationName            suboperationCount
ingestion-4757-10-18-3         3
ingestion-4757-10-18-4         4
ingestion-4757-10-18-3         6 …
Run Code Online (Sandbox Code Playgroud)

bash awk grouping grep count

0
推荐指数
1
解决办法
62
查看次数

标签 统计

awk ×1

bash ×1

count ×1

exception ×1

grep ×1

grouping ×1

infinity ×1

java ×1

juniper ×1

mockito ×1

postgresql ×1