This repository has been archived on 2021-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
geoportal-client/src/test/java/org/gcube/application/geoportal/common/model/ConcessioniTests.java

59 lines
1.9 KiB
Java

package org.gcube.application.geoportal.common.model;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicLong;
import org.gcube.application.geoportal.client.legacy.ConcessioniManager;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport.ValidationStatus;
import org.junit.Before;
import org.junit.Test;
public class ConcessioniTests {
static boolean STOP_ON_FAIL=true;
@Before
public void setScope(){
// TokenSetter.set("/gcube/devNext/NextNext");
TokenSetter.set("/gcube/devsec/devVRE");
}
@Test
public void readAll() throws Exception {
ConcessioniManager manager=new ConcessioniManager();
ArrayList<Concessione> found=manager.getList();
System.out.println("Found "+found.size()+" elements.");
final AtomicLong byId=new AtomicLong(0);
final ArrayList<Long> validIDs=new ArrayList<>();
final ArrayList<Long> imgs=new ArrayList<Long>();
final AtomicLong error=new AtomicLong(0);
found.forEach((Concessione c )->{
try {
manager.getById(c.getId()+"");
byId.incrementAndGet();
if(c.validate().getStatus().equals(ValidationStatus.PASSED))
validIDs.add(c.getId());
if(c.getImmaginiRappresentative()!=null&&c.getImmaginiRappresentative().size()>0)
imgs.add(c.getId());
}catch(Throwable t) {
error.incrementAndGet();
if(STOP_ON_FAIL) {
throw new RuntimeException(t);
}else t.printStackTrace(System.err);
}
});
System.out.println("Valid count "+validIDs.size()+ "Load BY ID : "+byId.get()+" Error : "+error.get()+" OUT OF "+found.size());
System.out.println("Valid IDS "+validIDs);
System.out.println("With imgs : "+imgs);
}
// @Test
// public void readOne() throws Exception {
// ConcessioniManager manager=new ConcessioniManager();
// System.out.println(manager.getById(67+""));
// }
}