Fixed Empty query result

This commit is contained in:
Fabio Sinibaldi 2021-12-01 11:13:50 +01:00
parent 70289ec603
commit 5d1d46e0c5
2 changed files with 6 additions and 3 deletions

View File

@ -225,6 +225,7 @@ public class ConcessioniOverMongo {
StringBuilder builder=new StringBuilder("[");
manager.query(Serialization.parseQuery(queryString))
.forEach(d->{builder.append(d.toJson()+",");});
if(builder.length()>1)
builder.deleteCharAt(builder.length()-1);
builder.append("]");
return builder.toString();

View File

@ -144,10 +144,12 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
public void query() throws Exception {
WebTarget target=target(PATH);
Iterator<Concessione> it = queryFile("lastRegistered.json", target);
assertEquals(1, count(it));
Iterator<Concessione> it;
assertEquals(1, count( queryFile("lastRegistered.json", target)));
assertEquals(0, count( queryFile("emptyresult.json",target)));
it=queryFile("firstRegistered.json", target);
assertEquals(1, count(it));