use of jakarta.nosql.tck.entities.Actor in project jnosql-diana by eclipse.
the class DefaultDocumentEntityConverterTest method shouldReturnErrorWhenToEntityIsNull.
@Test
public void shouldReturnErrorWhenToEntityIsNull() {
DocumentEntity entity = DocumentEntity.of("Actor");
Stream.of(documents).forEach(entity::add);
Actor actor = Actor.actorBuilder().build();
assertThrows(NullPointerException.class, () -> converter.toEntity(null, entity));
assertThrows(NullPointerException.class, () -> converter.toEntity(actor, null));
}
use of jakarta.nosql.tck.entities.Actor in project jnosql-diana by eclipse.
the class DefaultDocumentEntityConverterTest method shouldConvertEntityFromDocumentEntity2.
@Test
public void shouldConvertEntityFromDocumentEntity2() {
Movie movie = new Movie("Matrix", 2012, singleton("Actor"));
Director director = Director.builderDirector().withAge(12).withId(12).withName("Otavio").withPhones(Arrays.asList("234", "2342")).withMovie(movie).build();
DocumentEntity entity = converter.toDocument(director);
assertEquals(5, entity.size());
assertEquals(getValue(entity.find("name")), director.getName());
assertEquals(getValue(entity.find("age")), director.getAge());
assertEquals(getValue(entity.find("_id")), director.getId());
assertEquals(getValue(entity.find("phones")), director.getPhones());
Document subdocument = entity.find("movie").get();
List<Document> documents = subdocument.get(new TypeReference<List<Document>>() {
});
assertEquals(3, documents.size());
assertEquals("movie", subdocument.getName());
assertEquals(movie.getTitle(), getValue(documents.stream().filter(d -> "title".equals(d.getName())).findFirst()));
assertEquals(movie.getYear(), getValue(documents.stream().filter(d -> "year".equals(d.getName())).findFirst()));
assertEquals(movie.getActors(), getValue(documents.stream().filter(d -> "actors".equals(d.getName())).findFirst()));
}
use of jakarta.nosql.tck.entities.Actor in project jnosql-diana by eclipse.
the class DefaultDocumentEntityConverterTest method shouldConvertDocumentEntityFromEntity3.
@Test
public void shouldConvertDocumentEntityFromEntity3() {
DocumentEntity entity = DocumentEntity.of("Actor");
Stream.of(documents).forEach(entity::add);
Actor actor = converter.toEntity(entity);
assertNotNull(actor);
assertEquals(10, actor.getAge());
assertEquals(12L, actor.getId());
assertEquals(Arrays.asList("234", "2342"), actor.getPhones());
assertEquals(Collections.singletonMap("JavaZone", "Jedi"), actor.getMovieCharacter());
assertEquals(Collections.singletonMap("JavaZone", 10), actor.getMovieRating());
}
use of jakarta.nosql.tck.entities.Actor in project jnosql-diana by eclipse.
the class DefaultDocumentEntityConverterTest method shouldConvertDocumentEntityFromEntity2.
@Test
public void shouldConvertDocumentEntityFromEntity2() {
DocumentEntity entity = DocumentEntity.of("Actor");
Stream.of(documents).forEach(entity::add);
Actor actor = converter.toEntity(Actor.class, entity);
assertNotNull(actor);
assertEquals(10, actor.getAge());
assertEquals(12L, actor.getId());
assertEquals(Arrays.asList("234", "2342"), actor.getPhones());
assertEquals(Collections.singletonMap("JavaZone", "Jedi"), actor.getMovieCharacter());
assertEquals(Collections.singletonMap("JavaZone", 10), actor.getMovieRating());
}
use of jakarta.nosql.tck.entities.Actor in project jnosql-diana by eclipse.
the class DefaultDocumentEntityConverterTest method shouldConvertColumnEntityToExistEntity.
@Test
public void shouldConvertColumnEntityToExistEntity() {
DocumentEntity entity = DocumentEntity.of("Actor");
Stream.of(documents).forEach(entity::add);
Actor actor = Actor.actorBuilder().build();
Actor result = converter.toEntity(actor, entity);
assertSame(actor, result);
assertEquals(10, actor.getAge());
assertEquals(12L, actor.getId());
assertEquals(asList("234", "2342"), actor.getPhones());
assertEquals(Collections.singletonMap("JavaZone", "Jedi"), actor.getMovieCharacter());
assertEquals(Collections.singletonMap("JavaZone", 10), actor.getMovieRating());
}
Aggregations