-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:eclipse/jnosql
- Loading branch information
Showing
11 changed files
with
385 additions
and
78 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
40 changes: 40 additions & 0 deletions
40
...e/jnosql/mapping/reflection/DefaultArrayParameterMetaDataWhenEntityClassIsRecordTest.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,40 @@ | ||
/* | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
* | ||
* Contributors: | ||
* | ||
* Maximillian Arruda | ||
*/ | ||
package org.eclipse.jnosql.mapping.reflection; | ||
|
||
import org.eclipse.jnosql.mapping.metadata.ArrayParameterMetaData; | ||
import org.eclipse.jnosql.mapping.metadata.ClassConverter; | ||
import org.eclipse.jnosql.mapping.metadata.EntityMetadata; | ||
import org.eclipse.jnosql.mapping.reflection.entities.constructor.Game; | ||
import org.eclipse.jnosql.mapping.reflection.entities.constructor.Player; | ||
|
||
class DefaultArrayParameterMetaDataWhenEntityClassIsRecordTest implements DefaultArrayParameterMetaDataTest { | ||
|
||
@Override | ||
public ArrayParameterMetaData fieldMetadata() { | ||
ClassConverter converter = new ReflectionClassConverter(); | ||
EntityMetadata entityMetadata = converter.apply(Player.class); | ||
var constructor = entityMetadata.constructor(); | ||
return (ArrayParameterMetaData) | ||
constructor.parameters().stream().filter(p -> p.name().equals("games")) | ||
.findFirst().orElseThrow(); | ||
} | ||
|
||
@Override | ||
public Class<?> expectedElementType() { | ||
return Game.class; | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
.../jnosql/mapping/reflection/DefaultArrayParameterMetaDataWhenEntityIsRegularClassTest.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,54 @@ | ||
/* | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
* | ||
* Contributors: | ||
* | ||
* Otavio Santana | ||
* Maximillian Arruda | ||
*/ | ||
package org.eclipse.jnosql.mapping.reflection; | ||
|
||
import org.eclipse.jnosql.mapping.metadata.ArrayParameterMetaData; | ||
import org.eclipse.jnosql.mapping.metadata.ClassConverter; | ||
import org.eclipse.jnosql.mapping.metadata.ConstructorMetadata; | ||
import org.eclipse.jnosql.mapping.metadata.EntityMetadata; | ||
import org.eclipse.jnosql.mapping.reflection.entities.Book; | ||
import org.eclipse.jnosql.mapping.reflection.entities.constructor.BookUser; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class DefaultArrayParameterMetaDataWhenEntityIsRegularClassTest implements DefaultArrayParameterMetaDataTest { | ||
|
||
@Override | ||
public ArrayParameterMetaData fieldMetadata() { | ||
ClassConverter converter = new ReflectionClassConverter(); | ||
EntityMetadata entityMetadata = converter.apply(BookUser.class); | ||
ConstructorMetadata constructor = entityMetadata.constructor(); | ||
return (ArrayParameterMetaData) | ||
constructor.parameters().stream().filter(p -> p.name().equals("magazines")) | ||
.findFirst().orElseThrow(); | ||
} | ||
|
||
@Override | ||
public Class<?> expectedElementType() { | ||
return Book.class; | ||
} | ||
|
||
|
||
@Test | ||
void shouldArrayInstance() { | ||
List<Book> magazines = List.of(Book.builder().build(), Book.builder().build()); | ||
Book[] value = (Book[]) fieldMetadata().arrayInstance(magazines); | ||
assertThat(value).containsExactlyElementsOf(magazines); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ection/src/test/java/org/eclipse/jnosql/mapping/reflection/entities/constructor/Game.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,23 @@ | ||
/* | ||
* Copyright (c) 2022 Contributors to the Eclipse Foundation | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
* | ||
* Contributors: | ||
* | ||
* Otavio Santana | ||
* Maximillian Arruda | ||
*/ | ||
package org.eclipse.jnosql.mapping.reflection.entities.constructor; | ||
|
||
import jakarta.nosql.Entity; | ||
import jakarta.nosql.Id; | ||
|
||
@Entity | ||
public record Game(@Id String name) { | ||
} |
24 changes: 24 additions & 0 deletions
24
...tion/src/test/java/org/eclipse/jnosql/mapping/reflection/entities/constructor/Player.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,24 @@ | ||
/* | ||
* Copyright (c) 2022 Contributors to the Eclipse Foundation | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
* | ||
* Contributors: | ||
* | ||
* Otavio Santana | ||
* Maximillian Arruda | ||
*/ | ||
package org.eclipse.jnosql.mapping.reflection.entities.constructor; | ||
|
||
import jakarta.nosql.Column; | ||
import jakarta.nosql.Entity; | ||
import jakarta.nosql.Id; | ||
|
||
@Entity | ||
public record Player(@Id String nickname, @Column Game[] games) { | ||
} |
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.