Skip to content

Commit

Permalink
WIP test for quarkusio#16399
Browse files Browse the repository at this point in the history
  • Loading branch information
FroMage committed Apr 14, 2021
1 parent 2110988 commit c7c14a4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package io.quarkus.it.mongodb.panache.bugs;

import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.bson.codecs.pojo.annotations.BsonId;
import org.bson.codecs.pojo.annotations.BsonIgnore;
import org.bson.codecs.pojo.annotations.BsonProperty;

import io.quarkus.mongodb.panache.PanacheMongoEntityBase;

//@MongoEntity(collection = "Bug16399")
public class Bug16399Entity extends PanacheMongoEntityBase {
@BsonId
@BsonProperty("_id")
// @Schema(example = "516448966")
public Long id = -1L;

@BsonProperty("last_activity")
public LocalDateTime lastActivity = LocalDateTime.now();

@BsonIgnore
//TROUBLE METHOD CAUSES ERROR
public Bug16399Entity setLastActivity(final LocalDateTime... lastActivities) {
setLastActivity(Arrays.stream(lastActivities).max(LocalDateTime::compareTo).orElse(getTimeLastYear()));
return this;
}

private LocalDateTime getTimeLastYear() {
return null;
}

public LocalDateTime getLastActivity() {
return lastActivity;
}

public Bug16399Entity setLastActivity(final LocalDateTime lastActivity) {
this.lastActivity = lastActivity;
return this;
}

public static List<Bug16399Entity> dbFindById(final Iterable<?> entities) {
if (entities.iterator().hasNext()) {
return find("_id in ?1", entities).list();
}
return Collections.emptyList();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import io.quarkus.it.mongodb.panache.book.BookDetail;
import io.quarkus.it.mongodb.panache.bugs.Bug16399Entity;
import io.quarkus.it.mongodb.panache.person.Person;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
Expand Down Expand Up @@ -389,4 +390,11 @@ public void testMoreRepositoryFunctionalities() {
public void testBug13301() {
get("/bugs/13301").then().statusCode(200);
}

@Test
public void testBug16399() {
Bug16399Entity entity = new Bug16399Entity();
entity.persist();
Bug16399Entity.dbFindById(Arrays.asList(entity.id));
}
}

0 comments on commit c7c14a4

Please sign in to comment.