File tree 3 files changed +17
-5
lines changed
main/java/edu/kit/datamanager/ro_crate/entities
test/java/edu/kit/datamanager/ro_crate/entities/data 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 8
8
import com .fasterxml .jackson .databind .node .ArrayNode ;
9
9
import com .fasterxml .jackson .databind .node .ObjectNode ;
10
10
11
+ import edu .kit .datamanager .ro_crate .entities .data .RootDataEntity ;
11
12
import edu .kit .datamanager .ro_crate .entities .serializers .ObjectNodeSerializer ;
12
13
import edu .kit .datamanager .ro_crate .entities .validation .EntityValidation ;
13
14
import edu .kit .datamanager .ro_crate .entities .validation .JsonSchemaValidation ;
@@ -363,7 +364,7 @@ protected String getId() {
363
364
* @return the generic builder.
364
365
*/
365
366
public T setId (String id ) {
366
- if (id != null ) {
367
+ if (id != null && ! id . equals ( RootDataEntity . ID ) ) {
367
368
if (IdentifierUtils .isValidUri (id )) {
368
369
this .id = id ;
369
370
} else {
Original file line number Diff line number Diff line change 9
9
*/
10
10
public class RootDataEntity extends DataSetEntity {
11
11
12
- private static final String ID = "./" ;
12
+ public static final String ID = "./" ;
13
13
14
14
public RootDataEntity (AbstractDataSetBuilder <?> entityBuilder ) {
15
15
super (entityBuilder );
Original file line number Diff line number Diff line change 2
2
3
3
import com .fasterxml .jackson .databind .ObjectMapper ;
4
4
import com .fasterxml .jackson .databind .node .ObjectNode ;
5
- import static org .junit .jupiter .api .Assertions .assertEquals ;
6
- import static org .junit .jupiter .api .Assertions .assertTrue ;
7
5
8
6
import java .io .IOException ;
9
7
10
8
import edu .kit .datamanager .ro_crate .HelpFunctions ;
11
9
import edu .kit .datamanager .ro_crate .objectmapper .MyObjectMapper ;
12
10
import java .net .URI ;
13
11
import java .nio .file .Paths ;
14
- import static org . junit . jupiter . api . Assertions . assertNotNull ;
12
+ import java . util . Objects ;
15
13
16
14
import org .junit .jupiter .api .Test ;
17
15
16
+ import static org .junit .jupiter .api .Assertions .*;
17
+
18
18
/**
19
19
* @author Nikola Tzotchev on 5.2.2022 г.
20
20
* @version 1
21
21
*/
22
22
public class DataSetEntityTest {
23
23
24
+ @ Test
25
+ void testImpossibleRootId () {
26
+ DataSetEntity e = new DataSetEntity .DataSetBuilder ()
27
+ .setId ("./" )
28
+ .addProperty ("not_root" , true )
29
+ .build ();
30
+ assertNotNull (e .getId ());
31
+ assertFalse (e .getId ().isBlank ());
32
+ assertNotEquals (RootDataEntity .ID , e .getId ());
33
+ }
34
+
24
35
@ Test
25
36
void testSimpleDirDeserialization () throws IOException {
26
37
You can’t perform that action at this time.
0 commit comments