Skip to content

Commit 83c768d

Browse files
Merge branch 'test-cleanup' into dev
2 parents ca4195a + 052be73 commit 83c768d

File tree

6 files changed

+34
-185
lines changed

6 files changed

+34
-185
lines changed

tests/objectbox-java-test/src/main/java/io/objectbox/TestEntity.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@
2323

2424
import javax.annotation.Nullable;
2525

26-
/** In "real" entity would be annotated with @Entity. */
26+
import io.objectbox.annotation.Entity;
27+
import io.objectbox.annotation.Id;
28+
import io.objectbox.annotation.Unsigned;
29+
30+
/**
31+
* The annotations in this class have no effect as the Gradle plugin is not configured in this project. However, test
32+
* code builds a model like if the annotations were processed.
33+
* <p>
34+
* There is a matching test in the internal integration test project where this is tested and model builder code can be
35+
* "stolen" from.
36+
*/
37+
@Entity
2738
public class TestEntity {
2839

2940
public static final String STRING_VALUE_THROW_IN_CONSTRUCTOR =
@@ -32,7 +43,7 @@ public class TestEntity {
3243
public static final String EXCEPTION_IN_CONSTRUCTOR_MESSAGE =
3344
"Hello, this is an exception from TestEntity constructor";
3445

35-
/** In "real" entity would be annotated with @Id. */
46+
@Id
3647
private long id;
3748
private boolean simpleBoolean;
3849
private byte simpleByte;
@@ -47,11 +58,11 @@ public class TestEntity {
4758
/** Not-null value. */
4859
private String[] simpleStringArray;
4960
private List<String> simpleStringList;
50-
/** In "real" entity would be annotated with @Unsigned. */
61+
@Unsigned
5162
private short simpleShortU;
52-
/** In "real" entity would be annotated with @Unsigned. */
63+
@Unsigned
5364
private int simpleIntU;
54-
/** In "real" entity would be annotated with @Unsigned. */
65+
@Unsigned
5566
private long simpleLongU;
5667
private Map<String, Object> stringObjectMap;
5768
private Object flexProperty;

tests/objectbox-java-test/src/main/java/io/objectbox/TestEntityCursor.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2017-2024 ObjectBox Ltd. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,14 +16,16 @@
1616

1717
package io.objectbox;
1818

19+
import java.util.Map;
20+
1921
import io.objectbox.annotation.apihint.Internal;
2022
import io.objectbox.converter.FlexObjectConverter;
2123
import io.objectbox.converter.StringFlexMapConverter;
2224
import io.objectbox.internal.CursorFactory;
2325

24-
import java.util.Map;
26+
// NOTE: Instead of updating this by hand, copy changes from the internal integration test project after updating its
27+
// TestEntity. But make sure to keep the INT_NULL_HACK to make it work with tests here.
2528

26-
// NOTE: Copied from a plugin project (& removed some unused Properties).
2729
// THIS CODE IS GENERATED BY ObjectBox, DO NOT EDIT.
2830

2931
/**
@@ -86,6 +88,7 @@ public long getId(TestEntity entity) {
8688
*
8789
* @return The ID of the object within its box.
8890
*/
91+
@SuppressWarnings({"rawtypes", "unchecked"})
8992
@Override
9093
public long put(TestEntity entity) {
9194
short[] shortArray = entity.getShortArray();

tests/objectbox-java-test/src/main/java/io/objectbox/TestEntity_.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
/*
3-
* Copyright 2017 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2017-2024 ObjectBox Ltd. All rights reserved.
43
*
54
* Licensed under the Apache License, Version 2.0 (the "License");
65
* you may not use this file except in compliance with the License.
@@ -17,16 +16,18 @@
1716

1817
package io.objectbox;
1918

19+
import java.util.Map;
20+
2021
import io.objectbox.TestEntityCursor.Factory;
2122
import io.objectbox.annotation.apihint.Internal;
2223
import io.objectbox.converter.FlexObjectConverter;
2324
import io.objectbox.converter.StringFlexMapConverter;
2425
import io.objectbox.internal.CursorFactory;
2526
import io.objectbox.internal.IdGetter;
2627

27-
import java.util.Map;
28+
// NOTE: Instead of updating this by hand, copy changes from the internal integration test project after updating its
29+
// TestEntity.
2830

29-
// NOTE: Copied from a plugin project (& removed some unused Properties).
3031
// THIS CODE IS GENERATED BY ObjectBox, DO NOT EDIT.
3132

3233
/**
@@ -82,7 +83,7 @@ public final class TestEntity_ implements EntityInfo<TestEntity> {
8283
new io.objectbox.Property<>(__INSTANCE, 9, 10, byte[].class, "simpleByteArray");
8384

8485
public final static io.objectbox.Property<TestEntity> simpleStringArray =
85-
new io.objectbox.Property<>(__INSTANCE, 10, 11, String[].class, "simpleStringArray", false, "simpleStringArray");
86+
new io.objectbox.Property<>(__INSTANCE, 10, 11, String[].class, "simpleStringArray");
8687

8788
public final static io.objectbox.Property<TestEntity> simpleStringList =
8889
new io.objectbox.Property<>(__INSTANCE, 11, 15, java.util.List.class, "simpleStringList");
@@ -103,19 +104,19 @@ public final class TestEntity_ implements EntityInfo<TestEntity> {
103104
new io.objectbox.Property<>(__INSTANCE, 16, 17, byte[].class, "flexProperty", false, "flexProperty", FlexObjectConverter.class, Object.class);
104105

105106
public final static io.objectbox.Property<TestEntity> shortArray =
106-
new io.objectbox.Property<>(__INSTANCE, 17, 19, short[].class, "shortArray");
107+
new io.objectbox.Property<>(__INSTANCE, 17, 18, short[].class, "shortArray");
107108

108109
public final static io.objectbox.Property<TestEntity> charArray =
109-
new io.objectbox.Property<>(__INSTANCE, 18, 20, char[].class, "charArray");
110+
new io.objectbox.Property<>(__INSTANCE, 18, 19, char[].class, "charArray");
110111

111112
public final static io.objectbox.Property<TestEntity> intArray =
112-
new io.objectbox.Property<>(__INSTANCE, 19, 21, int[].class, "intArray");
113+
new io.objectbox.Property<>(__INSTANCE, 19, 20, int[].class, "intArray");
113114

114115
public final static io.objectbox.Property<TestEntity> longArray =
115-
new io.objectbox.Property<>(__INSTANCE, 20, 22, long[].class, "longArray");
116+
new io.objectbox.Property<>(__INSTANCE, 20, 21, long[].class, "longArray");
116117

117118
public final static io.objectbox.Property<TestEntity> floatArray =
118-
new io.objectbox.Property<>(__INSTANCE, 21, 18, float[].class, "floatArray");
119+
new io.objectbox.Property<>(__INSTANCE, 21, 22, float[].class, "floatArray");
119120

120121
public final static io.objectbox.Property<TestEntity> doubleArray =
121122
new io.objectbox.Property<>(__INSTANCE, 22, 23, double[].class, "doubleArray");

tests/objectbox-java-test/src/main/resources/testentity-index.json

Lines changed: 0 additions & 87 deletions
This file was deleted.

tests/objectbox-java-test/src/main/resources/testentity.json

Lines changed: 0 additions & 79 deletions
This file was deleted.

tests/objectbox-java-test/src/test/java/io/objectbox/BoxTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void testPut_notAssignedId_fails() {
9696
// Set ID that was not assigned
9797
entity.setId(1);
9898
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> box.put(entity));
99-
assertEquals(ex.getMessage(), "ID is higher or equal to internal ID sequence: 1 (vs. 1). Use ID 0 (zero) to insert new objects.");
99+
assertEquals("ID is higher or equal to internal ID sequence: 1 (vs. 1). Use ID 0 (zero) to insert new objects.", ex.getMessage());
100100
}
101101

102102
@Test

0 commit comments

Comments
 (0)