-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't merge collection property default value with graph value
- Loading branch information
1 parent
89e60c1
commit c38608c
Showing
4 changed files
with
121 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
test/src/test/java/org/neo4j/ogm/persistence/examples/numbers/Bucket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2002-2017 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this product except in compliance with the License. | ||
* | ||
* This product may include a number of subcomponents with | ||
* separate copyright notices and license terms. Your use of the source | ||
* code for these subcomponents is subject to the terms and | ||
* conditions of the subcomponent's license, as noted in the LICENSE file. | ||
*/ | ||
|
||
package org.neo4j.ogm.persistence.examples.numbers; | ||
|
||
import java.util.List; | ||
|
||
import org.neo4j.ogm.annotation.NodeEntity; | ||
|
||
import static com.google.common.collect.Lists.newArrayList; | ||
|
||
/** | ||
* @author Frantisek Hartman | ||
*/ | ||
@NodeEntity | ||
public class Bucket { | ||
|
||
Long id; | ||
|
||
// collection with default value | ||
List<Integer> numbers = newArrayList(1, 2, 3); | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public List<Integer> getNumbers() { | ||
return numbers; | ||
} | ||
|
||
public void setNumbers(List<Integer> numbers) { | ||
this.numbers = numbers; | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
test/src/test/java/org/neo4j/ogm/persistence/examples/numbers/BucketIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (c) 2002-2017 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this product except in compliance with the License. | ||
* | ||
* This product may include a number of subcomponents with | ||
* separate copyright notices and license terms. Your use of the source | ||
* code for these subcomponents is subject to the terms and | ||
* conditions of the subcomponent's license, as noted in the LICENSE file. | ||
*/ | ||
|
||
package org.neo4j.ogm.persistence.examples.numbers; | ||
|
||
import java.io.IOException; | ||
|
||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import org.neo4j.ogm.session.Session; | ||
import org.neo4j.ogm.session.SessionFactory; | ||
import org.neo4j.ogm.testutil.MultiDriverTestClass; | ||
|
||
import static java.util.Collections.emptyList; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author Frantisek Hartman | ||
*/ | ||
public class BucketIntegrationTest extends MultiDriverTestClass { | ||
|
||
private static SessionFactory sessionFactory; | ||
|
||
private Session session; | ||
|
||
@BeforeClass | ||
public static void oneTimeSetUp() { | ||
sessionFactory = new SessionFactory(driver, "org.neo4j.ogm.persistence.examples.numbers"); | ||
} | ||
|
||
@Before | ||
public void init() throws IOException { | ||
session = sessionFactory.openSession(); | ||
session.purgeDatabase(); | ||
} | ||
|
||
@Test | ||
public void savedBucketShouldHaveDefaultValue() throws Exception { | ||
Bucket bucket = new Bucket(); | ||
session.save(bucket); | ||
session.clear(); | ||
|
||
Bucket loaded = session.load(Bucket.class, bucket.getId()); | ||
assertThat(loaded.getNumbers()).containsOnly(1, 2, 3); | ||
} | ||
|
||
@Test | ||
public void emptiedBucketShouldBeEmptyAfterReload() throws Exception { | ||
Bucket bucket = new Bucket(); | ||
bucket.setNumbers(emptyList()); | ||
session.save(bucket); | ||
session.clear(); | ||
|
||
Bucket loaded = session.load(Bucket.class, bucket.getId()); | ||
assertThat(loaded.getNumbers()).isEmpty(); | ||
} | ||
} |