Improved code and test
This commit is contained in:
parent
2cc004df4c
commit
161977ae00
|
@ -193,15 +193,16 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
|||
return callsForList;
|
||||
}
|
||||
|
||||
public void deleteCallsForToVirtualService(List<CallsFor<EService, VirtualService>> callsForList) throws SchemaViolationException, NotFoundException, ResourceRegistryException {
|
||||
public List<CallsFor<EService, VirtualService>> deleteCallsForToVirtualService(List<CallsFor<EService, VirtualService>> callsForList) throws SchemaViolationException, NotFoundException, ResourceRegistryException {
|
||||
for(CallsFor<EService, VirtualService> cf : callsForList) {
|
||||
resourceRegistryPublisher.delete(cf);
|
||||
}
|
||||
return callsForList;
|
||||
}
|
||||
|
||||
public void deleteCallsForToVirtualService() throws Exception {
|
||||
public List<CallsFor<EService, VirtualService>> deleteCallsForToVirtualService() throws Exception {
|
||||
List<CallsFor<EService, VirtualService>> callsForList = getCallsForToVirtualService();
|
||||
deleteCallsForToVirtualService(callsForList);
|
||||
return deleteCallsForToVirtualService(callsForList);
|
||||
}
|
||||
|
||||
public CallsFor<EService, VirtualService> createCallsForToVirtualService() throws Exception {
|
||||
|
@ -211,7 +212,13 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
|||
|
||||
int size = callsForList.size();
|
||||
|
||||
UUID gcatEServiceUUID = UUID.fromString(gcatEServiceID);
|
||||
|
||||
if(size>1) {
|
||||
logger.warn("There are {} instances of {} relation beetween gcat Eservice with UUID {} and the {} (catalogue-virtual-service). This is very strange because there should be only one. We are going to delete them and recreated a new one.",
|
||||
callsForList.size(), CallsFor.NAME, gcatEServiceID, VirtualService.NAME);
|
||||
logger.trace("{} relation instances that are going to be deleted are {}",
|
||||
CallsFor.NAME, ElementMapper.marshal(callsForList));
|
||||
deleteCallsForToVirtualService(callsForList);
|
||||
size = 0;
|
||||
}
|
||||
|
@ -221,7 +228,6 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy<SimpleF
|
|||
propagationConstraint.setAddConstraint(AddConstraint.unpropagate);
|
||||
propagationConstraint.setRemoveConstraint(RemoveConstraint.keep);
|
||||
EService gcatEService = new EServiceImpl();
|
||||
UUID gcatEServiceUUID = UUID.fromString(gcatEServiceID);
|
||||
gcatEService.setHeader(new HeaderImpl(gcatEServiceUUID));
|
||||
VirtualService virtualService = queryVirtualService();
|
||||
callsFor = new CallsForImpl<EService, VirtualService>(gcatEService, virtualService, propagationConstraint);
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
package org.gcube.gcat.configuration.isproxies;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.gcat.ContextTest;
|
||||
import org.gcube.gcat.configuration.service.ServiceCatalogueConfiguration;
|
||||
import org.gcube.informationsystem.utils.ElementMapper;
|
||||
import org.gcube.resourcemanagement.model.reference.entities.facets.SimpleFacet;
|
||||
import org.gcube.resourcemanagement.model.reference.entities.resources.EService;
|
||||
import org.gcube.resourcemanagement.model.reference.entities.resources.VirtualService;
|
||||
import org.gcube.resourcemanagement.model.reference.relations.isrelatedto.CallsFor;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -15,11 +21,13 @@ public class FacetBasedISConfigurationProxyTest extends ContextTest {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(FacetBasedISConfigurationProxyTest.class);
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
FacetBasedISConfigurationProxy fbiscp = FacetBasedISConfigurationProxyFactory.getInstance();
|
||||
fbiscp.setGcatEServiceID("f00bbacd-92b8-46d7-b41c-828f71a78753");
|
||||
fbiscp.createCallsForToVirtualService();
|
||||
CallsFor<EService, VirtualService> callsFor = fbiscp.createCallsForToVirtualService();
|
||||
logger.debug("Created {}", ElementMapper.marshal(callsFor));
|
||||
|
||||
SimpleFacet simpleFacet = fbiscp.getISResource();
|
||||
logger.debug("{}", ElementMapper.marshal(simpleFacet));
|
||||
|
@ -28,7 +36,8 @@ public class FacetBasedISConfigurationProxyTest extends ContextTest {
|
|||
logger.debug("{}", catalogueConfiguration.toJsonString());
|
||||
logger.debug("{}", catalogueConfiguration.toJsonString(true));
|
||||
|
||||
fbiscp.deleteCallsForToVirtualService();
|
||||
List<CallsFor<EService, VirtualService>> callsForList = fbiscp.deleteCallsForToVirtualService();
|
||||
logger.debug("Deleted {} {} relations {}", callsForList.size(), CallsFor.NAME, ElementMapper.marshal(callsForList));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue