2018-03-02 16:26:19 +01:00
|
|
|
package org.gcube.informationsystem.resourceregistry.context;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
import org.gcube.informationsystem.impl.entity.ContextImpl;
|
|
|
|
import org.gcube.informationsystem.impl.utils.ISMapper;
|
|
|
|
import org.gcube.informationsystem.model.entity.Context;
|
2018-07-20 16:14:33 +02:00
|
|
|
import org.gcube.informationsystem.resourceregistry.ScopedTest;
|
2018-03-02 16:26:19 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
2018-04-12 15:04:25 +02:00
|
|
|
import org.junit.Test;
|
2018-03-02 16:26:19 +01:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2018-09-06 14:48:30 +02:00
|
|
|
public class ContextManagementTest extends ScopedTest {
|
2018-03-02 16:26:19 +01:00
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(ContextManagementTest.class);
|
|
|
|
|
|
|
|
protected Context read(UUID uuid) throws ResourceRegistryException, IOException {
|
|
|
|
ContextManagement contextManagement = new ContextManagement();
|
|
|
|
contextManagement.setUUID(uuid);
|
|
|
|
String contextString = contextManagement.read();
|
|
|
|
logger.debug("Read {}", contextString);
|
|
|
|
return ISMapper.unmarshal(Context.class, contextString);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Context create(Context context) throws ResourceRegistryException, IOException {
|
|
|
|
ContextManagement contextManagement = new ContextManagement();
|
|
|
|
contextManagement.setJSON(ISMapper.marshal(context));
|
|
|
|
String contextString = contextManagement.create();
|
|
|
|
logger.debug("Created {}", contextString);
|
|
|
|
Context c = ISMapper.unmarshal(Context.class, contextString);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
public void createPreContext() throws Exception {
|
|
|
|
Context gcube = new ContextImpl("gcube");
|
|
|
|
gcube = create(gcube);
|
|
|
|
|
|
|
|
Context preprod = new ContextImpl("preprod");
|
|
|
|
preprod.setParent(gcube);
|
|
|
|
preprod = create(preprod);
|
|
|
|
|
|
|
|
Context parthenosVRE = new ContextImpl("PARTHENOS_PRE");
|
|
|
|
parthenosVRE.setParent(preprod);
|
|
|
|
parthenosVRE = create(parthenosVRE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-04-12 15:04:25 +02:00
|
|
|
@Test
|
2018-07-20 16:14:33 +02:00
|
|
|
public void createContexts() throws Exception {
|
2018-04-12 15:04:25 +02:00
|
|
|
ContextCreator contextCreator = new ContextCreator();
|
2018-06-04 12:31:09 +02:00
|
|
|
contextCreator.all();
|
2018-04-12 15:04:25 +02:00
|
|
|
}
|
|
|
|
|
2018-07-20 16:14:33 +02:00
|
|
|
@Test
|
|
|
|
public void testContext() throws Exception {
|
|
|
|
ScopedTest.setContext(ScopedTest.PROD);
|
|
|
|
}
|
2018-04-12 15:04:25 +02:00
|
|
|
|
2018-03-02 16:26:19 +01:00
|
|
|
}
|