|
24 | 24 |
|
25 | 25 | class UpsertAssemblerContextTest { |
26 | 26 | private final MockConfig config = new MockConfig(); |
27 | | - |
28 | 27 | private final PreparedSqlBuilder buf = |
29 | 28 | new PreparedSqlBuilder(config, SqlKind.BATCH_INSERT, SqlLogType.RAW); |
30 | 29 | private final Dept_ metaDept = new Dept_(); |
31 | 30 | private final List<EntityPropertyType<?, ?>> propertyTypes = |
32 | 31 | metaDept.allPropertyMetamodels().stream().map(PropertyMetamodel::asType).collect(toList()); |
33 | 32 |
|
| 33 | + @Test |
| 34 | + void onDuplicateKeyException() { |
| 35 | + List<EntityPropertyType<?, ?>> keys = |
| 36 | + propertyTypes.stream().filter(EntityPropertyType::isId).collect(toList()); |
| 37 | + List<Tuple2<EntityPropertyType<?, ?>, InParameter<?>>> insertValues = |
| 38 | + propertyTypes.stream() |
| 39 | + .filter(c -> !c.isId()) |
| 40 | + .map(c -> new Tuple2<EntityPropertyType<?, ?>, InParameter<?>>(c, mockInParameter())) |
| 41 | + .collect(toList()); |
| 42 | + List<Tuple2<EntityPropertyType<?, ?>, UpsertSetValue>> setValues = |
| 43 | + propertyTypes.stream() |
| 44 | + .filter(c -> !c.isId()) |
| 45 | + .map( |
| 46 | + c -> |
| 47 | + new Tuple2<EntityPropertyType<?, ?>, UpsertSetValue>( |
| 48 | + c, new UpsertSetValue.Prop(c))) |
| 49 | + .collect(toList()); |
| 50 | + DomaIllegalArgumentException ex = |
| 51 | + assertThrows( |
| 52 | + DomaIllegalArgumentException.class, |
| 53 | + () -> { |
| 54 | + new UpsertAssemblerContext( |
| 55 | + buf, |
| 56 | + metaDept.asType(), |
| 57 | + DuplicateKeyType.EXCEPTION, |
| 58 | + Naming.NONE, |
| 59 | + config.getDialect(), |
| 60 | + keys, |
| 61 | + insertValues, |
| 62 | + setValues); |
| 63 | + }); |
| 64 | + System.out.println(ex.getMessage()); |
| 65 | + } |
| 66 | + |
34 | 67 | @Test |
35 | 68 | void onDuplicateKeyUpdate() { |
36 | 69 | List<EntityPropertyType<?, ?>> keys = |
|
0 commit comments