2014-03-11 12:37:01 +01:00
|
|
|
package org.gcube.smartgears.utils.sweeper.test;
|
|
|
|
|
2020-04-07 15:25:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.gcube.common.resources.gcore.HostingNode;
|
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
|
|
import org.gcube.informationsystem.publisher.RegistryPublisher;
|
|
|
|
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
|
|
|
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
|
|
|
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
|
|
|
import org.gcube.resources.discovery.icclient.ICFactory;
|
2014-03-11 12:37:01 +01:00
|
|
|
import org.gcube.smartgears.utils.sweeper.Sweeper;
|
|
|
|
import org.junit.Before;
|
2020-04-07 15:25:38 +02:00
|
|
|
import org.junit.Test;
|
2014-03-11 12:37:01 +01:00
|
|
|
|
|
|
|
public class SweeperTest {
|
|
|
|
|
|
|
|
Sweeper sw = null;
|
|
|
|
|
|
|
|
@Before
|
|
|
|
public void setUp(){
|
|
|
|
try {
|
2020-04-07 15:25:38 +02:00
|
|
|
sw = new Sweeper("/home/lucio/Smartgears");
|
2014-03-11 12:37:01 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-07 15:25:38 +02:00
|
|
|
@Test
|
|
|
|
public void deleteHNs() {
|
|
|
|
sw.forceDeleteHostingNode();
|
|
|
|
}
|
2014-03-11 12:37:01 +01:00
|
|
|
|
2020-04-07 15:25:38 +02:00
|
|
|
@Test
|
|
|
|
public void deleteFromScope() {
|
|
|
|
|
|
|
|
RegistryPublisher rp=RegistryPublisherFactory.create();
|
|
|
|
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
|
|
|
DiscoveryClient<HostingNode> client = ICFactory.clientFor(HostingNode.class);
|
|
|
|
SimpleQuery query = ICFactory.queryFor(HostingNode.class);
|
|
|
|
query.addCondition("$resource/ID/text() = 'c8201474-a8cd-440f-9f62-a1e1b107ceb6'");
|
|
|
|
List<HostingNode> nodes = client.submit(query);
|
|
|
|
rp.remove(nodes.get(0));
|
|
|
|
}
|
2014-03-11 12:37:01 +01:00
|
|
|
}
|