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

View File

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