@ -33,7 +33,7 @@ public class DummyProjectTest extends AbstractProfiledDocumentsTests{
String fieldName = "fileset" ;
String fieldDefinition = "section." + Field . CHILDREN + "[?(@.fileset)]" ;
String filename = " sample.tif";
String filename = " concessioni/ sample.tif";
@Override
@ -146,137 +146,16 @@ public class DummyProjectTest extends AbstractProfiledDocumentsTests{
return doc ;
}
@Test
public void testUnlock ( ) throws Exception {
assumeTrue ( GCubeTest . isTestInfrastructureEnabled ( ) ) ;
// Not automatic, needs generation of locked project
assumeTrue ( false ) ;
String id = "627e87bb02ad3d1a2e0e9e18" ;
String ucd = "profiledConcessioni" ;
Project p = check ( target ( InterfaceConstants . Methods . PROJECTS ) . path ( ucd ) . path ( InterfaceConstants . Methods . FORCE_UNLOCK ) . path ( id ) . request ( MediaType . APPLICATION_JSON ) .
put ( Entity . entity ( "" , MediaType . APPLICATION_JSON ) ) , Project . class ) ;
assertNull ( p . getLock ( ) ) ;
}
@Test
public void testRelationships ( ) throws Exception {
assumeTrue ( GCubeTest . isTestInfrastructureEnabled ( ) ) ;
Project a = createNew ( new Document ( "key" , "value" ) ) ;
Project b = createNew ( new Document ( "key" , "value" ) ) ;
// set relation a -- precedes --> b
System . out . println ( "Setting relation.." ) ;
String relId = "precedes" ;
a = check ( baseTarget ( ) .
path ( InterfaceConstants . Methods . RELATIONSHIP ) .
path ( a . getId ( ) ) .
path ( relId ) .
queryParam ( InterfaceConstants . Parameters . TARGET_UCD , b . getProfileID ( ) ) .
queryParam ( InterfaceConstants . Parameters . TARGET_ID , b . getId ( ) ) .
request ( MediaType . APPLICATION_JSON ) .
put ( Entity . json ( "" ) ) , Project . class ) ;
// check set relation in a
System . out . println ( "Checking relation a->b" ) ;
assertTrue ( a . getRelationships ( ) ! = null & & a . getRelationships ( ) . size ( ) = = 1 ) ;
Relationship rel = a . getRelationships ( ) . get ( 0 ) ;
assertEquals ( rel . getRelationshipName ( ) , relId ) ;
assertEquals ( rel . getTargetUCD ( ) , b . getProfileID ( ) ) ;
assertEquals ( rel . getTargetID ( ) , b . getId ( ) ) ;
// TODO TBD check reciprocity : expected relation b -- follows -> a
// delete relation
System . out . println ( "Deleting relation a->b" ) ;
a = check ( baseTarget ( ) .
path ( InterfaceConstants . Methods . RELATIONSHIP ) .
path ( a . getId ( ) ) .
path ( relId ) .
queryParam ( InterfaceConstants . Parameters . TARGET_UCD , b . getProfileID ( ) ) .
queryParam ( InterfaceConstants . Parameters . TARGET_ID , b . getId ( ) ) .
request ( MediaType . APPLICATION_JSON ) .
delete ( ) , Project . class ) ;
// check deleted
System . out . println ( "Checking deleted relation" ) ;
assertTrue ( a . getRelationships ( ) = = null | | a . getRelationships ( ) . isEmpty ( ) ) ;
}
// Not automatic, needs generation of locked project
// @Test
// public void testSDI() throws Exception {
// // Create new
// Project doc = createNew(new Document("posizionamentoScavo",new Document("title","Mio pos")));
//
// // register filesets
// doc = upload(
// new StorageUtils(),
// doc.getId(),
// "posizionamentoScavo","fileset",
// "posizionamentoScavo."+Field.CHILDREN+"[?(@.fileset)]",
// null,
// RegisterFileSetRequest.ClashOptions.REPLACE_EXISTING,
// "pos.shp","pos.shx");
//
// System.out.println("Registered posizionamento, result is "+ Serialization.write(doc));
//
// // invoke step SUBMIT-FOR-REVIEW
// StepExecutionRequest req=new StepExecutionRequest();
// req.setStepID("SUBMIT-FOR-REVIEW");
// doc=step(doc.getId(),req);
// System.out.println(doc);
// if(doc.getLifecycleInformation().getErrorMessages()!=null) {
// System.out.println("ERROR MESSAGES");
// doc.getLifecycleInformation().getErrorMessages().forEach(s -> System.out.println(s));
// }
// if(doc.getLifecycleInformation().getWarningMessages()!=null) {
// System.out.println("WARNING MESSAGES");
// doc.getLifecycleInformation().getWarningMessages().forEach(s -> System.out.println(s));
// }
//
// assertTrue(doc.getLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK));
//
// JSONPathWrapper wrapper = new JSONPathWrapper(doc.getTheDocument().toJson());
// RegisteredFileSet fs = Serialization.convert(wrapper.getByPath("$..fileset").get(0),RegisteredFileSet.class);
// assertTrue(fs!=null);
// assertTrue(fs.getPayloads().size()==2);
// assertTrue(fs.getMaterializations().size()>0);
//
//
// for(Object matObj : wrapper.getByPath("$..[?(@."+ Materialization.TYPE +" == '"+GCubeSDILayer.GCUBE_SDY_LAYER_TYPE+"' )]")){
// GCubeSDILayer layer = Serialization.convert(matObj, GCubeSDILayer.class);
// System.out.println("Checking Layer : "+layer);
// assertTrue(layer.getType().equals(GCubeSDILayer.GCUBE_SDY_LAYER_TYPE));
// assertTrue(layer.getOGCLinks().size()>0);
// assertTrue(layer.getPlatformInfo().size()>0);
// assertTrue(layer.getBBox()!=null);
// }
//
// // Checking platform info GeoServer
// for(Object platformObj : wrapper.getByPath("$..[?(@."+ Materialization.TYPE +" == 'GeoServer' )]")){
// Document platform=Serialization.asDocument(platformObj);
// assertTrue(platform.containsKey("layerName"));
// assertTrue(platform.containsKey("workspace"));
// assertTrue(platform.containsKey("storeName"));
// assertTrue(platform.containsKey("persistencePath"));
// assertTrue(platform.get("files",List.class).size()==2);
// }
//
//
// req.setStepID("APPROVE DRAFT");
// doc=step(doc.getId(),req);
// if(doc.getLifecycleInformation().getErrorMessages()!=null) {
// System.out.println("ERROR MESSAGES");
// doc.getLifecycleInformation().getErrorMessages().forEach(s -> System.out.println(s));
// }
// if(doc.getLifecycleInformation().getWarningMessages()!=null) {
// System.out.println("WARNING MESSAGES");
// doc.getLifecycleInformation().getWarningMessages().forEach(s -> System.out.println(s));
// }
//
// assertTrue(doc.getLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK));
//
// public void testUnlock() throws Exception {
// assumeTrue(GCubeTest.isTestInfrastructureEnabled());
// assumeTrue(false);
// String id = "627e87bb02ad3d1a2e0e9e18";
// String ucd = "profiledConcessioni";
// Project p =check(target(InterfaceConstants.Methods.PROJECTS).path(ucd).path(InterfaceConstants.Methods.FORCE_UNLOCK).path(id).request(MediaType.APPLICATION_JSON).
// put(Entity.entity("", MediaType.APPLICATION_JSON)), Project.class);
// assertNull(p.getLock());
// }
}