2022-02-24 18:09:30 +01:00
package org.gcube.application.geoportal.service.profiledDocuments ;
2022-02-14 17:06:32 +01:00
2022-08-31 18:06:19 +02:00
import lombok.extern.slf4j.Slf4j ;
2022-02-14 17:06:32 +01:00
import org.bson.Document ;
2022-02-15 19:02:44 +01:00
import org.gcube.application.cms.serialization.Serialization ;
2022-03-04 14:23:20 +01:00
import org.gcube.application.geoportal.common.model.document.Project ;
2022-04-11 17:23:27 +02:00
import org.gcube.application.geoportal.common.model.document.identification.SpatialReference ;
2022-02-14 17:06:32 +01:00
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation ;
2022-03-04 14:23:20 +01:00
import org.gcube.application.geoportal.common.model.useCaseDescriptor.Field ;
2022-02-14 17:06:32 +01:00
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest ;
import org.gcube.application.geoportal.common.model.rest.StepExecutionRequest ;
import org.gcube.application.geoportal.common.rest.InterfaceConstants ;
import org.gcube.application.geoportal.common.utils.StorageUtils ;
2022-04-08 11:13:25 +02:00
import org.gcube.application.geoportal.service.utils.UserUtils ;
2022-02-14 17:06:32 +01:00
import org.junit.Test ;
import javax.ws.rs.client.WebTarget ;
2022-08-31 18:06:19 +02:00
import java.time.LocalDateTime ;
2022-02-14 17:06:32 +01:00
import static org.junit.Assert.assertEquals ;
import static org.junit.Assert.assertTrue ;
2022-08-31 18:06:19 +02:00
@Slf4j
2022-02-16 17:12:54 +01:00
public class ProfiledConcessioniTests extends AbstractProfiledDocumentsTests {
2022-02-14 17:06:32 +01:00
2022-04-08 11:13:25 +02:00
2022-02-14 17:06:32 +01:00
@Override
protected WebTarget baseTarget ( ) {
String testProfileId = " profiledConcessioni " ;
2022-08-31 18:06:19 +02:00
return super . baseTarget ( ) . path ( testProfileId ) ;
2022-02-14 17:06:32 +01:00
}
@Test
public void testSDI ( ) throws Exception {
2022-04-08 11:13:25 +02:00
UserUtils . DEFAULT_ROLES . add ( " Data-Manager " ) ;
2022-02-14 17:06:32 +01:00
// Create new
2022-08-31 18:06:19 +02:00
2022-03-04 11:30:48 +01:00
Document theDoc = Document . parse ( " { \ n " +
" \" posizionamentoScavo \" :{ \ n " +
" \ t \" titolo \" : \" mio titolo \" }} " ) ;
2022-08-31 18:06:19 +02:00
theDoc . put ( " startTime " , LocalDateTime . now ( ) ) ;
log . debug ( " Sending {} " , theDoc ) ;
log . debug ( " AS JSON : {} " , Serialization . write ( theDoc ) ) ;
2022-03-04 14:23:20 +01:00
Project doc = createNew ( theDoc ) ;
2022-03-04 11:30:48 +01:00
2022-08-31 18:06:19 +02:00
log . debug ( " Received : {} " , doc ) ;
log . debug ( " AS JSON : {} " , Serialization . write ( doc ) ) ;
2022-03-04 11:30:48 +01:00
2022-02-16 17:12:54 +01:00
2022-02-14 17:06:32 +01:00
// register filesets
doc = upload (
new StorageUtils ( ) ,
2022-02-23 17:13:22 +01:00
doc . getId ( ) ,
2022-05-18 18:24:57 +02:00
" $.posizionamentoScavo " ,
2022-03-22 17:29:25 +01:00
" fileset " ,
2022-05-18 18:24:57 +02:00
" $.posizionamentoScavo. " + Field . CHILDREN + " [?(@.fileset)] " ,
2022-03-04 11:30:48 +01:00
null ,
2022-02-14 17:06:32 +01:00
RegisterFileSetRequest . ClashOptions . MERGE_EXISTING ,
" pos.shp " ) ;
2022-02-15 19:02:44 +01:00
System . out . println ( " Registered posizionamento, result is " + Serialization . write ( doc ) ) ;
2022-02-14 17:06:32 +01:00
// invoke step SUBMIT-FOR-REVIEW
2022-03-07 17:59:06 +01:00
StepExecutionRequest submitReq = new StepExecutionRequest ( ) ;
submitReq . setStepID ( " SUBMIT-FOR-REVIEW " ) ;
2022-09-20 12:20:04 +02:00
// doc=step(doc.getId(),submitReq);
doc = step ( " 630f912755e2947b0278c1be " , submitReq ) ;
2022-02-14 17:06:32 +01:00
System . out . println ( doc ) ;
assertTrue ( doc . getLifecycleInformation ( ) . getLastOperationStatus ( ) . equals ( LifecycleInformation . Status . OK ) ) ;
2022-03-07 17:59:06 +01:00
// invoke step Publish
StepExecutionRequest approveDraftReq = new StepExecutionRequest ( ) ;
2022-04-08 13:17:52 +02:00
approveDraftReq . setStepID ( " APPROVE-SUBMITTED " ) ;
2022-03-07 17:59:06 +01:00
doc = step ( doc . getId ( ) , approveDraftReq ) ;
System . out . println ( doc ) ;
assertTrue ( doc . getLifecycleInformation ( ) . getLastOperationStatus ( ) . equals ( LifecycleInformation . Status . OK ) ) ;
2022-04-11 17:23:27 +02:00
assertTrue ( doc . getIdentificationReferenceByType ( SpatialReference . SPATIAL_REFERENCE_TYPE ) . size ( ) = = 1 ) ;
System . out . println ( " Project " + doc . getId ( ) + " published with spatial reference " + doc . getIdentificationReferenceByType ( SpatialReference . SPATIAL_REFERENCE_TYPE ) . get ( 0 ) ) ;
2022-02-14 17:06:32 +01:00
}
2022-08-31 18:06:19 +02:00
@Test
public void delete ( ) throws Exception {
Document theDoc = Document . parse ( " { \ n " +
" \" posizionamentoScavo \" :{ \ n " +
" \ t \" titolo \" : \" mio titolo \" }} " ) ;
theDoc . put ( " startTime " , LocalDateTime . now ( ) ) ;
log . debug ( " sendi " ) ;
Project doc = createNew ( theDoc ) ;
}
2022-02-14 17:06:32 +01:00
}