Fixed Deletion

This commit is contained in:
Fabio Sinibaldi 2022-05-17 11:43:50 +02:00
parent ce9f3be3fc
commit 33155051ae
5 changed files with 29 additions and 13 deletions

View File

@ -29,8 +29,11 @@ import java.util.List;
@Slf4j @Slf4j
public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements LifecycleManager { public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements LifecycleManager {
public static final String PLUGIN_ID="DEFAULT-SINGLE-STEP";
public SimpleLifeCycleManager() { public SimpleLifeCycleManager() {
DESCRIPTOR.setId("DEFAULT-SINGLE-STEP"); DESCRIPTOR.setId(PLUGIN_ID);
} }

View File

@ -11,7 +11,7 @@ public class EventExecutionReport extends DocumentHandlingReport<EventExecutionR
public EventExecutionReport(EventExecutionRequest req) throws InvalidPluginRequestException { public EventExecutionReport(EventExecutionRequest req) throws InvalidPluginRequestException {
super(req); super(req);
this.setToSetLifecycleInformation(theRequest.getDocument().getLifecycleInformation().cleanState()); this.setToSetLifecycleInformation(theRequest.getDocument().getLifecycleInformation().cleanState());
this.getToSetLifecycleInformation().setLastOperationStatus(LifecycleInformation.Status.OK);
} }

View File

@ -377,7 +377,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
WorkspaceManager ws = new WorkspaceManager(); WorkspaceManager ws = new WorkspaceManager();
// Get All registered Filesets with payloads // Get All registered Filesets with payloads
JSONPathWrapper wrapper = new JSONPathWrapper(useCaseDescriptor.getSchema().toJson()); JSONPathWrapper wrapper = new JSONPathWrapper(useCaseDescriptor.getSchema().toJson());
for (Object obj : wrapper.getByPath("..*[?(@." + RegisteredFileSet.PAYLOADS + ")]")) { for (Object obj : wrapper.getByPath("$..[?(@." + RegisteredFileSet.PAYLOADS + ")]")) {
Document fs = Serialization.asDocument(obj); Document fs = Serialization.asDocument(obj);
log.debug("Deleting {}",obj); log.debug("Deleting {}",obj);
String folderId = fs.getString(RegisteredFileSet.FOLDER_ID); String folderId = fs.getString(RegisteredFileSet.FOLDER_ID);

View File

@ -97,7 +97,10 @@ public abstract class AbstractProfiledDocumentsTests extends BasicServiceTestUni
return doc; return doc;
} }
protected void delete(String id) throws Exception {
check(baseTarget().path(id).request(MediaType.APPLICATION_JSON).
delete(), null);
}
protected Project update(String id, Document newContent)throws Exception { protected Project update(String id, Document newContent)throws Exception {

View File

@ -61,12 +61,28 @@ public class DummyProjectTest extends AbstractProfiledDocumentsTests{
@Test @Test
public void testUploadFileSet() throws Exception { public void testUploadFileSet() throws Exception {
assumeTrue(GCubeTest.isTestInfrastructureEnabled()); assumeTrue(GCubeTest.isTestInfrastructureEnabled());
Project doc = createWithFileSet();
JSONPathWrapper wrapper = new JSONPathWrapper(doc.getTheDocument().toJson());
assertTrue("Relazione exists",wrapper.getMatchingPaths("section").size()==1);
RegisteredFileSet fs = Serialization.convert(wrapper.getByPath("section.fileset").get(0),RegisteredFileSet.class);
assertTrue(fs.getPayloads().size()==1);
assertTrue(fs.getString("customField").equals("customFieldValue"));
}
@Test
public void testDelete() throws Exception {
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
delete(createWithFileSet().getId());
}
private Project createWithFileSet() throws Exception {
Document baseDoc=new Document(); Document baseDoc=new Document();
baseDoc.put("section",new Document("title","My Title")); baseDoc.put("section",new Document("title","My Title"));
Project doc = createNew(baseDoc); Project doc = createNew(baseDoc);
assertTrue(doc.getTheDocument().containsKey("section"));
// Try set releazione scavo // Try set releazione scavo
String parentPath="section"; String parentPath="section";
@ -86,13 +102,7 @@ public class DummyProjectTest extends AbstractProfiledDocumentsTests{
new Document("customField","customFieldValue"), new Document("customField","customFieldValue"),
RegisterFileSetRequest.ClashOptions.REPLACE_EXISTING, RegisterFileSetRequest.ClashOptions.REPLACE_EXISTING,
filename); filename);
return doc;
JSONPathWrapper wrapper = new JSONPathWrapper(doc.getTheDocument().toJson());
assertTrue("Relazione exists",wrapper.getMatchingPaths(parentPath).size()==1);
RegisteredFileSet fs = Serialization.convert(wrapper.getByPath(parentPath+"."+fieldName).get(0),RegisteredFileSet.class);
assertTrue(fs.getPayloads().size()==1);
assertTrue(fs.getString("customField").equals("customFieldValue"));
} }
// @Test // @Test