diff --git a/examples/business-id-runtime/src/test/java/io/teaql/examples/businessid/BusinessIdRuntimeExampleTest.java b/examples/business-id-runtime/src/test/java/io/teaql/examples/businessid/BusinessIdRuntimeExampleTest.java index 651604f30..7e4a78586 100644 --- a/examples/business-id-runtime/src/test/java/io/teaql/examples/businessid/BusinessIdRuntimeExampleTest.java +++ b/examples/business-id-runtime/src/test/java/io/teaql/examples/businessid/BusinessIdRuntimeExampleTest.java @@ -37,7 +37,7 @@ private static final class Order extends BaseEntity implements BusinessIdSlot { private OrderNumber orderNumber; private Order(long id) { - updateId(id); + __internalSet("id", id); } @Override diff --git a/examples/scalar-type-probe/GeneratedExplicitNullTest.java b/examples/scalar-type-probe/GeneratedExplicitNullTest.java index 45d4b2a04..3c1035f92 100644 --- a/examples/scalar-type-probe/GeneratedExplicitNullTest.java +++ b/examples/scalar-type-probe/GeneratedExplicitNullTest.java @@ -57,7 +57,7 @@ public class GeneratedExplicitNullTest { assertFalse(full.__internalHasMutationLedger()); full.updateOptionalInteger(37);full.updateOptionalString(null); full.updateProperty("optional_integer",37);full.updateProperty("optional_string",null); - full.handleUpdate("optional_integer",37,37);full.updateId(id);full.updateVersion(1L); + full.handleUpdate("optional_integer",37,37); assertSame(state,full.__internalLoadState());assertEquals(EntityStatus.PERSISTED,full.get$status()); assertTrue(full.getUpdatedProperties().isEmpty());assertFalse(full.__internalHasMutationLedger()); full.auditAs("Confirm equal loaded values produce no write").save(f.context); @@ -68,7 +68,7 @@ public class GeneratedExplicitNullTest { boolean hadLedger=reference.__internalHasMutationLedger(); var referenceLedger=hadLedger?reference.getEntityMutationLedger():null; assertFalse(reference.isPropertyLoaded("version")); - assertThrows(TeaQLRuntimeException.class,()->reference.updateVersion(null)); + assertThrows(TeaQLRuntimeException.class,()->reference.updateProperty("version",null)); assertSame(referenceState,reference.__internalLoadState());assertEquals(EntityStatus.REFER,reference.get$status()); assertEquals(hadLedger,reference.__internalHasMutationLedger()); if(hadLedger)assertSame(referenceLedger,reference.getEntityMutationLedger()); diff --git a/examples/scalar-type-probe/GeneratedRejectedMutationTest.java b/examples/scalar-type-probe/GeneratedRejectedMutationTest.java index 28e0e3750..ec37eecff 100644 --- a/examples/scalar-type-probe/GeneratedRejectedMutationTest.java +++ b/examples/scalar-type-probe/GeneratedRejectedMutationTest.java @@ -36,7 +36,7 @@ static void unchanged(TypePlatform reference,LoadState state){ long before=f.data.calls;int auditCount=f.audits.size(),policyCount=f.policies.size();int rejected=0; assertThrows(TeaQLRuntimeException.class,()->reference.updateName("must not appear"));unchanged(reference,state);rejected++; assertThrows(TeaQLRuntimeException.class,()->reference.updateProperty("name","must not appear either"));unchanged(reference,state);rejected++; - assertThrows(TeaQLRuntimeException.class,()->reference.updateVersion(9L));unchanged(reference,state);rejected++; + assertThrows(TeaQLRuntimeException.class,()->reference.updateProperty("version",9L));unchanged(reference,state);rejected++; // Explicit negative fault injection through the legacy runtime cache // seam; this is not an application API discovery/recommendation. assertThrows(TeaQLRuntimeException.class,()->reference.cacheRelation("negative_cache",owner));unchanged(reference,state);rejected++; diff --git a/examples/secret-provider/src/test/java/io/teaql/examples/secret/SecretProviderExampleTest.java b/examples/secret-provider/src/test/java/io/teaql/examples/secret/SecretProviderExampleTest.java index 6c05a8909..5e3e7cb5c 100644 --- a/examples/secret-provider/src/test/java/io/teaql/examples/secret/SecretProviderExampleTest.java +++ b/examples/secret-provider/src/test/java/io/teaql/examples/secret/SecretProviderExampleTest.java @@ -31,7 +31,7 @@ private static final class LedgerProbe extends BaseEntity { private String name = "original"; private LedgerProbe(long id) { - updateId(id); + __internalInitializeNewEntityId(id); } private void updateName(String replacement) { diff --git a/teaql-core/src/main/java/io/teaql/core/BaseEntity.java b/teaql-core/src/main/java/io/teaql/core/BaseEntity.java index a2168879f..42c893122 100644 --- a/teaql-core/src/main/java/io/teaql/core/BaseEntity.java +++ b/teaql-core/src/main/java/io/teaql/core/BaseEntity.java @@ -104,7 +104,7 @@ public Long getId() { return id; } - public BaseEntity updateId(Long id) { + BaseEntity updateId(Long id) { if (isPropertyLoaded(ID_PROPERTY) && ObjectUtil.equals(this.id, id)) { return this; } @@ -113,13 +113,13 @@ public BaseEntity updateId(Long id) { return this; } - @FrameworkInternal("Generated schema bootstrap fixed-ID creation only") + @FrameworkInternal("New entity ID initialization for Q creation and generated bootstrap") public void __internalInitializeNewEntityId(Long fixedId) { if (fixedId == null || fixedId <= 0) { - throw new IllegalArgumentException("Generated bootstrap ID must be positive"); + throw new IllegalArgumentException("Creation ID must be positive"); } if (id != null || !newItem()) { - throw new IllegalStateException("Fixed bootstrap ID can only initialize a new entity"); + throw new IllegalStateException("Creation ID can only initialize a new entity"); } id = fixedId; markPropertyLoaded(ID_PROPERTY); @@ -131,7 +131,7 @@ public Long getVersion() { return version; } - public BaseEntity updateVersion(Long version) { + BaseEntity updateVersion(Long version) { if (isPropertyLoaded(VERSION_PROPERTY) && ObjectUtil.equals(this.version, version)) { return this; } diff --git a/teaql-core/src/main/java/io/teaql/core/ExecutableRequest.java b/teaql-core/src/main/java/io/teaql/core/ExecutableRequest.java index a2ddc12ee..f62cfdd4d 100644 --- a/teaql-core/src/main/java/io/teaql/core/ExecutableRequest.java +++ b/teaql-core/src/main/java/io/teaql/core/ExecutableRequest.java @@ -37,6 +37,23 @@ public T newEntity(UserContext context) { return NewEntityLifecycle.initialize(context, request.getTypeName(), initialized); } + /** Creates a new aggregate with an explicit ID; never changes an existing entity. */ + public T newEntityWithId(Long id, UserContext context) { + if (context == null) throw new IllegalArgumentException("UserContext is required for entity creation"); + if (id == null || id <= 0) throw new IllegalArgumentException("Creation ID must be positive"); + T entity = request.internalNewEntity(); + if (!(entity instanceof BaseEntity base)) { + throw new IllegalArgumentException("Explicit-ID creation requires a generated BaseEntity"); + } + InternalIdGenerationService ids = context.capability(InternalIdGenerationService.class); + if (ids == null) { + throw new IllegalStateException("Explicit-ID creation requires an InternalIdGenerationService"); + } + ids.ensureFloor(base.typeName(), id); + base.__internalInitializeNewEntityId(id); + return context.initializeEntity(request.getTypeName(), entity); + } + public SmartList executeForList(UserContext context) { return context.executeForList(this); } diff --git a/teaql-core/src/main/java/io/teaql/core/InternalIdGenerationService.java b/teaql-core/src/main/java/io/teaql/core/InternalIdGenerationService.java index fe2468d2d..a18332fc0 100644 --- a/teaql-core/src/main/java/io/teaql/core/InternalIdGenerationService.java +++ b/teaql-core/src/main/java/io/teaql/core/InternalIdGenerationService.java @@ -47,7 +47,8 @@ default long nextId(String typeName) { /** * Advances the allocation state for {@code typeName} so future generated IDs are greater - * than {@code floor}. Generated schema bootstrap uses this after reserving model-defined IDs. + * than {@code floor}. Generated schema bootstrap and explicit-ID entity creation use this + * to reserve identities before subsequent automatic allocation. */ default void ensureFloor(String typeName, long floor) { throw new UnsupportedOperationException( diff --git a/teaql-core/src/main/java/io/teaql/core/value/BaseEntityExpression.java b/teaql-core/src/main/java/io/teaql/core/value/BaseEntityExpression.java index f20b2a6c3..12fe8dcf6 100644 --- a/teaql-core/src/main/java/io/teaql/core/value/BaseEntityExpression.java +++ b/teaql-core/src/main/java/io/teaql/core/value/BaseEntityExpression.java @@ -28,11 +28,4 @@ default Expression save(UserContext userContext) { }); } - default Expression updateId(Long id) { - return apply( - entity -> { - entity.__internalSet("id", id); - return entity; - }); - } } diff --git a/teaql-core/src/test/java/io/teaql/core/BaseRequestTest.java b/teaql-core/src/test/java/io/teaql/core/BaseRequestTest.java index e2ee2660e..487187ebb 100644 --- a/teaql-core/src/test/java/io/teaql/core/BaseRequestTest.java +++ b/teaql-core/src/test/java/io/teaql/core/BaseRequestTest.java @@ -358,6 +358,46 @@ public void testExecutableRequestCreatesEntityThroughTrustedContext() { assertTrue(entity.isPropertyLoaded("id")); } + @Test + public void testExplicitIdCreationInitializesBeforeTrustedContextAndDoesNotExposeSystemUpdaters() throws Exception { + java.util.concurrent.atomic.AtomicInteger initialized = new java.util.concurrent.atomic.AtomicInteger(); + java.util.concurrent.atomic.AtomicLong floor = new java.util.concurrent.atomic.AtomicLong(); + InternalIdGenerationService ids = new InternalIdGenerationService() { + public Long generateId(UserContext current, Entity entity) { return floor.incrementAndGet(); } + public void ensureFloor(String type, long value) { floor.accumulateAndGet(value, Math::max); } + }; + UserContext context = (UserContext) Proxy.newProxyInstance( + UserContext.class.getClassLoader(), new Class[] { UserContext.class }, + (proxy, method, args) -> { + if (method.getName().equals("capability") && args[0] == InternalIdGenerationService.class) return ids; + if (method.getName().equals("initializeEntity")) { + BaseEntity value = (BaseEntity) args[1]; + assertEquals(Long.valueOf(1234L), value.getId()); + assertEquals(EntityStatus.NEW, value.get$status()); + initialized.incrementAndGet(); + return value; + } + throw new UnsupportedOperationException(method.getName()); + }); + var executable = new BaseRequest.TempRequest(BaseEntity.class, "BaseEntity", BaseEntity::new) + .internalComment("Create imported entity").purpose("Preserve external identity"); + BaseEntity entity = (BaseEntity) executable.newEntityWithId(1234L, context); + assertEquals(Long.valueOf(1234L), entity.getId()); + assertEquals(1, initialized.get()); + assertEquals(1234L, floor.get()); + assertEquals(Long.valueOf(1235L), ids.generateId(context, entity)); + org.junit.Assert.assertThrows(IllegalArgumentException.class, () -> executable.newEntityWithId(0L, context)); + org.junit.Assert.assertThrows(IllegalArgumentException.class, () -> executable.newEntityWithId(null, context)); + assertEquals(1, initialized.get()); + UserContext missingIds = (UserContext) Proxy.newProxyInstance( + UserContext.class.getClassLoader(), new Class[] { UserContext.class }, + (proxy, method, args) -> null); + org.junit.Assert.assertThrows(IllegalStateException.class, () -> executable.newEntityWithId(7L, missingIds)); + org.junit.Assert.assertThrows(NoSuchMethodException.class, () -> BaseEntity.class.getMethod("updateId", Long.class)); + org.junit.Assert.assertThrows(NoSuchMethodException.class, () -> BaseEntity.class.getMethod("updateVersion", Long.class)); + org.junit.Assert.assertThrows(NoSuchMethodException.class, () -> io.teaql.core.value.BaseEntityExpression.class.getMethod("updateId", Long.class)); + } + @Test public void testEnhanceChildren() { BaseRequest.TempRequest subReq = new BaseRequest.TempRequest(BaseEntity.class, "ChildEntity"); diff --git a/teaql-core/src/test/java/io/teaql/core/checker/CheckerTest.java b/teaql-core/src/test/java/io/teaql/core/checker/CheckerTest.java index 6487c596d..cb99d13aa 100644 --- a/teaql-core/src/test/java/io/teaql/core/checker/CheckerTest.java +++ b/teaql-core/src/test/java/io/teaql/core/checker/CheckerTest.java @@ -71,7 +71,7 @@ public void testMarkAsCheckedAndNeedCheck() { // Check another entity when list is not null but does not contain DummyEntity entity2 = new DummyEntity(); - entity2.updateId(2L); + entity2.__internalSet("id", 2L); assertTrue(checker.needCheck(context, entity2)); // Check null diff --git a/teaql-core/src/test/java/io/teaql/core/value/LoadedPropertyExpressionTest.java b/teaql-core/src/test/java/io/teaql/core/value/LoadedPropertyExpressionTest.java index 9e9c78f1b..8e3c7717c 100644 --- a/teaql-core/src/test/java/io/teaql/core/value/LoadedPropertyExpressionTest.java +++ b/teaql-core/src/test/java/io/teaql/core/value/LoadedPropertyExpressionTest.java @@ -15,19 +15,19 @@ static class Subject extends BaseEntity { @Test public void distinguishesValueLoadedNullAndNotLoaded() { - Subject value = new Subject(); value.updateId(1L); value.loadName("TeaQL"); + Subject value = new Subject(); value.__internalSet("id", 1L); value.loadName("TeaQL"); Expression root = new ValueExpression<>(value); Expression expression = new LoadedPropertyExpression<>(root, "name", Subject::getName); assertEquals("TeaQL", expression.eval()); assertEquals("TeaQL", expression.orIfNull("fallback")); - Subject loadedNull = new Subject(); loadedNull.updateId(2L); loadedNull.loadName(null); + Subject loadedNull = new Subject(); loadedNull.__internalSet("id", 2L); loadedNull.loadName(null); Expression nullExpression = new LoadedPropertyExpression<>( new ValueExpression<>(loadedNull), "name", Subject::getName); assertNull(nullExpression.eval()); assertEquals("fallback", nullExpression.orIfNull("fallback")); - Subject partial = new Subject(); partial.updateId(3L); + Subject partial = new Subject(); partial.__internalSet("id", 3L); Expression missing = new LoadedPropertyExpression<>( new ValueExpression<>(partial), "name", Subject::getName); TeaQLNotLoadedException error = assertThrows(TeaQLNotLoadedException.class, missing::eval); diff --git a/teaql-core/src/test/java/io/teaql/core/value/SmartListExpressionTest.java b/teaql-core/src/test/java/io/teaql/core/value/SmartListExpressionTest.java index 6843f4834..571ce9790 100644 --- a/teaql-core/src/test/java/io/teaql/core/value/SmartListExpressionTest.java +++ b/teaql-core/src/test/java/io/teaql/core/value/SmartListExpressionTest.java @@ -9,7 +9,7 @@ public class SmartListExpressionTest { static class DummyEntity extends BaseEntity { - public DummyEntity(Long id) { updateId(id); } + public DummyEntity(Long id) { __internalSet("id", id); } @Override public String typeName() { return "dummy"; } } diff --git a/teaql-data-service-sql/src/test/java/io/teaql/dataservice/sql/SqlStatementTelemetryTest.java b/teaql-data-service-sql/src/test/java/io/teaql/dataservice/sql/SqlStatementTelemetryTest.java index ff5cd35fe..5e45008b9 100644 --- a/teaql-data-service-sql/src/test/java/io/teaql/dataservice/sql/SqlStatementTelemetryTest.java +++ b/teaql-data-service-sql/src/test/java/io/teaql/dataservice/sql/SqlStatementTelemetryTest.java @@ -72,7 +72,7 @@ private TeaQLDatabase database(InvocationHandler action) throws Exception { @Test public void writeAndReadbackUseDistinctExecutionsAndRetainLineageWithoutEntityIds() throws Exception { var db = database((proxy, method, args) -> method.getName().equals("update") ? 1 : List.of(Map.of("id", 17L))); var entity = new BaseEntity(); - entity.updateId(17L); + entity.__internalSet("id", 17L); var intent = MutationIntent.of("save school"); var lineage = List.of(new TraceNode(TraceKind.AUDIT_REASON, "School", 99887766L, "save school")); var trace = SqlExecutionTrace.mutation(entity, lineage, "update", intent); diff --git a/teaql-jackson/src/test/java/io/teaql/jackson/BaseEntitySerializationTest.java b/teaql-jackson/src/test/java/io/teaql/jackson/BaseEntitySerializationTest.java index 484156efd..b8d11ffdd 100644 --- a/teaql-jackson/src/test/java/io/teaql/jackson/BaseEntitySerializationTest.java +++ b/teaql-jackson/src/test/java/io/teaql/jackson/BaseEntitySerializationTest.java @@ -94,9 +94,9 @@ static final class JsonGraphEntity extends BaseEntity { } @Test public void smartListBackReferencesKeepTheActiveSerializationPath() throws Exception { - var parent = new NamedRelationsEntity(); parent.updateId(7L); + var parent = new NamedRelationsEntity(); parent.__internalSet("id", 7L); parent.childList = io.teaql.core.SmartList.unloaded().map(child -> child); - var child = new JsonGraphEntity(); child.updateId(9L); child.__internalSet("child", parent); + var child = new JsonGraphEntity(); child.__internalSet("id", 9L); child.__internalSet("child", parent); parent.childList.add(child); var mapper = new ObjectMapper().registerModule(TeaQLModule.INSTANCE); var tree = mapper.valueToTree(parent); @@ -144,8 +144,8 @@ public static class CyclicEntity extends BaseEntity { @Test public void cyclicIndexedGraphsUseIdentityReferencesAndDoNotRetainAPathAcrossWrites() throws Exception { - var first = new CyclicEntity(); first.updateId(1L); first.updateVersion(1L); - var second = new CyclicEntity(); second.updateId(2L); second.updateVersion(1L); + var first = new CyclicEntity(); first.__internalSet("id", 1L); first.__internalSet("version", 1L); + var second = new CyclicEntity(); second.__internalSet("id", 2L); second.__internalSet("version", 1L); first.__internalSet("peer", second); second.__internalSet("peer", first); var mapper = new ObjectMapper().registerModule(TeaQLModule.INSTANCE); var json = mapper.readTree(mapper.writeValueAsString(first)); @@ -157,8 +157,8 @@ public void cyclicIndexedGraphsUseIdentityReferencesAndDoNotRetainAPathAcrossWri @Test public void sharedReferencesOutsideTheActivePathAreNotReducedToIdentityOnly() throws Exception { - var first = new CyclicEntity(); first.updateId(1L); first.updateVersion(1L); - var second = new CyclicEntity(); second.updateId(2L); second.updateVersion(1L); + var first = new CyclicEntity(); first.__internalSet("id", 1L); first.__internalSet("version", 1L); + var second = new CyclicEntity(); second.__internalSet("id", 2L); second.__internalSet("version", 1L); first.__internalSet("peer", second); second.putAdditional("_label", "shared child"); first.putAdditional("_again", second); @@ -251,8 +251,8 @@ public void setName(String name) { @Test public void serializesDynamicPropertiesWithTeaQLModule() throws Exception { BaseEntity entity = new BaseEntity(); - entity.updateId(1001L); - entity.updateVersion(7L); + entity.__internalSet("id", 1001L); + entity.__internalSet("version", 7L); entity.setComment("internal comment"); entity.setTraceChain(java.util.List.of(new io.teaql.core.TraceNode( io.teaql.core.TraceKind.AUDIT_REASON, entity.typeName(), 1001L, "internal trace"))); @@ -290,7 +290,7 @@ public void deserializesBaseEntityWithoutBeanMutation() throws Exception { @Test public void serializesBaseEntitySubclassesWithTeaQLSerializer() throws Exception { NamedEntity entity = new NamedEntity(); - entity.updateId(1001L); + entity.__internalSet("id", 1001L); entity.setName("should-not-use-bean-getter"); entity.putAdditional("#customer_asset_no", "A-10086"); diff --git a/teaql-runtime/src/test/java/io/teaql/runtime/TeaQLRuntimeTest.java b/teaql-runtime/src/test/java/io/teaql/runtime/TeaQLRuntimeTest.java index d65c1ff30..3a72f8291 100644 --- a/teaql-runtime/src/test/java/io/teaql/runtime/TeaQLRuntimeTest.java +++ b/teaql-runtime/src/test/java/io/teaql/runtime/TeaQLRuntimeTest.java @@ -220,7 +220,7 @@ public static class PageQueryExecutor implements QueryExecutor { SmartList rows = new SmartList<>(); for (int id = request.getSlice().getOffset() + 1; id <= request.getSlice().getOffset() + request.getSlice().getSize(); id++) { - DummyEntity entity = new DummyEntity(); entity.updateId((long) id); rows.add(entity); + DummyEntity entity = new DummyEntity(); entity.__internalSet("id", (long) id); rows.add(entity); } return new DefaultQueryResult(rows); } @@ -261,7 +261,7 @@ private static MutationPolicy allowingPolicy( private static DummyEntity changedEntity(long id, String comment) { DummyEntity entity = new DummyEntity(); - entity.updateId(id); + entity.__internalSet("id", id); entity.__internalSet("version", 1L); entity.set$status(EntityStatus.PERSISTED); entity.updateProperty("name", "private-value"); @@ -391,7 +391,7 @@ public void graphPolicyReviewsAllOperationsExactlyOnce() { .mutationPolicyRegistry(key -> java.util.Optional.of(policy)) .build(); ContainerEntity root = new ContainerEntity(); - root.updateId(910L); + root.__internalSet("id", 910L); root.__internalSet("version", 1L); root.set$status(EntityStatus.PERSISTED); DummyEntity child = changedEntity(911L, "child change"); @@ -951,28 +951,28 @@ public void testSaveGraphLedgerClassificationAndExecutionOrder() throws Exceptio root.setComment("root comment"); DummyEntity e1 = new DummyEntity(); // to delete - e1.updateId(101L); + e1.__internalSet("id", 101L); e1.__internalSet("version", 1L); e1.set$status(EntityStatus.PERSISTED); e1.setEntityMutationLedger(root); e1.markForDeletion(); DummyEntity e2 = new DummyEntity(); // to update - e2.updateId(102L); + e2.__internalSet("id", 102L); e2.__internalSet("version", 1L); e2.set$status(EntityStatus.PERSISTED); e2.setEntityMutationLedger(root); e2.updateProperty("name", "updated"); DummyEntity e3 = new DummyEntity(); // to insert - e3.updateId(103L); + e3.__internalSet("id", 103L); e3.set$status(EntityStatus.NEW); e3.setEntityMutationLedger(root); e3.updateProperty("name", "inserted"); root.markAsNew(new EntityKey(e3.typeName(), e3.getId())); DummyEntity e4 = new DummyEntity(); // to delete only - e4.updateId(104L); + e4.__internalSet("id", 104L); e4.__internalSet("version", 1L); e4.set$status(EntityStatus.PERSISTED); e4.setEntityMutationLedger(root); @@ -1037,22 +1037,22 @@ public void testSaveGraphMergesRelatedEntityMutationLedgers() { .build(); ContainerEntity rootEntity = new ContainerEntity(); - rootEntity.updateId(1L); + rootEntity.__internalSet("id", 1L); rootEntity.__internalSet("version", 1L); rootEntity.set$status(EntityStatus.PERSISTED); DummyEntity toOneChild = new DummyEntity(); - toOneChild.updateId(2L); + toOneChild.__internalSet("id", 2L); toOneChild.__internalSet("version", 1L); toOneChild.set$status(EntityStatus.PERSISTED); DummyEntity listChild1 = new DummyEntity(); - listChild1.updateId(3L); + listChild1.__internalSet("id", 3L); listChild1.__internalSet("version", 1L); listChild1.set$status(EntityStatus.PERSISTED); DummyEntity listChild2 = new DummyEntity(); - listChild2.updateId(4L); + listChild2.__internalSet("id", 4L); listChild2.__internalSet("version", 1L); listChild2.set$status(EntityStatus.PERSISTED); @@ -1087,14 +1087,14 @@ public void testSaveGraphDoesNotConsumeIndependentLedgerFromSameContext() { DefaultUserContext context = new DefaultUserContext(runtime); DummyEntity first = new DummyEntity(); - first.updateId(11L); + first.__internalSet("id", 11L); first.__internalSet("version", 1L); first.set$status(EntityStatus.PERSISTED); first.updateProperty("name", "save me"); first.setComment("save first graph only"); DummyEntity independent = new DummyEntity(); - independent.updateId(22L); + independent.__internalSet("id", 22L); independent.__internalSet("version", 1L); independent.set$status(EntityStatus.PERSISTED); independent.updateProperty("name", "keep pending"); @@ -1128,14 +1128,14 @@ public MutationResult mutate(UserContext context, PersistenceMutation request) { DefaultUserContext context = new DefaultUserContext(runtime); DummyEntity failing = new DummyEntity(); - failing.updateId(31L); + failing.__internalSet("id", 31L); failing.__internalSet("version", 1L); failing.set$status(EntityStatus.PERSISTED); failing.updateProperty("name", "must remain pending"); failing.setComment("fail this graph"); DummyEntity independent = new DummyEntity(); - independent.updateId(32L); + independent.__internalSet("id", 32L); independent.__internalSet("version", 1L); independent.set$status(EntityStatus.PERSISTED); independent.updateProperty("name", "independent pending"); diff --git a/teaql-tfp-endpoint/src/test/java/io/teaql/tfp/TfpConformanceServer.java b/teaql-tfp-endpoint/src/test/java/io/teaql/tfp/TfpConformanceServer.java index ac3262858..8a26d2397 100644 --- a/teaql-tfp-endpoint/src/test/java/io/teaql/tfp/TfpConformanceServer.java +++ b/teaql-tfp-endpoint/src/test/java/io/teaql/tfp/TfpConformanceServer.java @@ -124,17 +124,17 @@ private static QueryExecutor queryExecutor() { return new QueryExecutor() { public QueryResult query(io.teaql.core.UserContext context, QueryRequest request) { CustomerOrder order = new CustomerOrder(); - order.updateId(7L); order.updateVersion(1L); order.setTenantId(1L); + order.__internalSet("id", 7L); order.__internalSet("version", 1L); order.setTenantId(1L); order.setStatus("NEW"); order.setOrderNumber("ORD-007"); order.setReviewed(Boolean.TRUE); SmartList rows = new SmartList<>(); rows.add(order); var searchRequest = ((io.teaql.runtime.DefaultQueryRequest) request).getSearchRequest(); if (!searchRequest.getFacetRequests().isEmpty()) { SmartList statuses = new SmartList<>(); - OrderStatus newest = new OrderStatus(); newest.updateId(1001L); + OrderStatus newest = new OrderStatus(); newest.__internalSet("id", 1001L); newest.setCode("NEW"); newest.setLabel("New"); newest.addDynamicProperty("orderCount", 1); statuses.add(newest); - OrderStatus paid = new OrderStatus(); paid.updateId(1002L); + OrderStatus paid = new OrderStatus(); paid.__internalSet("id", 1002L); paid.setCode("PAID"); paid.setLabel("Paid"); paid.addDynamicProperty("orderCount", 0); statuses.add(paid); rows.addFacet(searchRequest.getFacetRequests().get(0).getFacetName(), statuses);