-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revive destroyed entities when added to an association
- Loading branch information
1 parent
2559e11
commit c3014c9
Showing
9 changed files
with
298 additions
and
9 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package mesh | ||
{ | ||
import mesh.model.source.FixtureSource; | ||
import mesh.model.source.MultiSource; | ||
|
||
public class TestSource extends MultiSource | ||
{ | ||
public function TestSource() | ||
{ | ||
super(); | ||
map(Customer, new FixtureSource(Customer)); | ||
map(Account, new FixtureSource(Account)); | ||
map(Person, new FixtureSource(Person)); | ||
map(Order, new FixtureSource(Order)); | ||
} | ||
} | ||
} |
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,66 @@ | ||
package mesh.model | ||
{ | ||
import mesh.Name; | ||
import mesh.Person; | ||
import mesh.TestSource; | ||
import mesh.model.store.Store; | ||
|
||
import org.flexunit.assertThat; | ||
import org.hamcrest.object.equalTo; | ||
|
||
public class EntityRevivalTests | ||
{ | ||
private var _person:Person; | ||
private var _store:Store; | ||
|
||
[Before] | ||
public function setup():void | ||
{ | ||
_person = new Person({name:new Name("Jimmy", "Page"), age:67}); | ||
|
||
_store = new Store(new TestSource()); | ||
_store.add(_person); | ||
_store.commit(); | ||
} | ||
|
||
[Test] | ||
public function testStatusIsNewIfRevivedWithoutID():void | ||
{ | ||
var person:Person = new Person({name:new Name("Steve", "Jobs")}); | ||
_store.add(person); | ||
|
||
person.destroy(); | ||
person.revive(); | ||
assertThat(person.status.isNew, equalTo(true)); | ||
} | ||
|
||
[Test] | ||
public function testStatusIsPersistedAndDirtyIfRevivedWithPropertyChanges():void | ||
{ | ||
_person.age++; | ||
|
||
_person.destroy(); | ||
_person.revive(); | ||
assertThat(_person.status.isPersisted && _person.status.isDirty, equalTo(true)); | ||
} | ||
|
||
[Test] | ||
public function testStatusIsPersistedAndSyncedIfNoPropertyChanges():void | ||
{ | ||
_person.destroy(); | ||
_person.revive(); | ||
assertThat(_person.status.isPersisted && !_person.status.isDirty, equalTo(true)); | ||
} | ||
|
||
[Test] | ||
public function testStatusIsNewIfDestroyedAndSynced():void | ||
{ | ||
_person.destroy(); | ||
_store.commit(); | ||
|
||
_person.revive(); | ||
assertThat(_person.id, equalTo(null)); | ||
assertThat(_person.status.isNew, equalTo(true)); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.