Search in sources :

Example 31 with CatalogService

use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.

the class ExecutionEngineImplTest method createOrder.

protected Order createOrder(String name, Map<String, String> params) {
    ExecutionState state = new ExecutionState();
    modelClient.save(state);
    Order order = new Order();
    order.setExecutionStateId(state.getId());
    CatalogService service = new CatalogService();
    service.setLabel(name);
    modelClient.save(service);
    order.setCatalogServiceId(service.getId());
    modelClient.save(order);
    int index = 0;
    for (Map.Entry<String, String> entry : params.entrySet()) {
        OrderParameter param = new OrderParameter();
        param.setLabel(entry.getKey());
        param.setValue(entry.getValue());
        param.setOrderId(order.getId());
        modelClient.save(param);
    }
    return order;
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) ExecutionState(com.emc.storageos.db.client.model.uimodels.ExecutionState) OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) Map(java.util.Map)

Example 32 with CatalogService

use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.

the class CatalogServiceTest method testReparent.

@Test
public void testReparent() throws Exception {
    _logger.info("Starting reparent CatalogService test");
    ModelClient modelClient = getModelClient();
    CatalogCategory parent1 = createCategoryWithLabel("Parent 1");
    modelClient.save(parent1);
    CatalogCategory parent2 = createCategoryWithLabel("Parent 2");
    modelClient.save(parent2);
    CatalogService service = createWithLabel("Service");
    setParent(parent1, service);
    modelClient.save(service);
    List<CatalogService> parent1Children = modelClient.catalogServices().findByCatalogCategory(parent1.getId());
    Assert.assertEquals(1, parent1Children.size());
    Assert.assertEquals(service.getId(), parent1Children.get(0).getId());
    List<CatalogService> parent2Children = modelClient.catalogServices().findByCatalogCategory(parent2.getId());
    Assert.assertEquals(0, parent2Children.size());
    setParent(parent2, service);
    modelClient.save(service);
    parent1Children = modelClient.catalogServices().findByCatalogCategory(parent1.getId());
    Assert.assertEquals(0, parent1Children.size());
    parent2Children = modelClient.catalogServices().findByCatalogCategory(parent2.getId());
    Assert.assertEquals(1, parent2Children.size());
    Assert.assertEquals(service.getId(), parent2Children.get(0).getId());
}
Also used : ModelClient(com.emc.sa.model.dao.ModelClient) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Example 33 with CatalogService

use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.

the class CatalogServiceTest method testPersistObject.

@Test
public void testPersistObject() throws Exception {
    _logger.info("Starting persist CatalogService test");
    CatalogService model = new CatalogService();
    model.setId(URIUtil.createId(CatalogService.class));
    model.setLabel("foo");
    model.setApprovalRequired(true);
    model.setBaseService("my service");
    URI ewUri = URIUtil.createId(ExecutionWindow.class);
    NamedURI ewId = new NamedURI(ewUri, "ewId");
    model.setDefaultExecutionWindowId(ewId);
    model.setDescription("my desc");
    model.setExecutionWindowRequired(true);
    model.setImage("my image");
    model.setMaxSize(42);
    model.setTitle("my title");
    save(model);
    model = findById(model.getId());
    Assert.assertNotNull(model);
    Assert.assertEquals("foo", model.getLabel());
    Assert.assertEquals(true, model.getApprovalRequired());
    Assert.assertEquals("my service", model.getBaseService());
    Assert.assertEquals(ewId, model.getDefaultExecutionWindowId());
    Assert.assertEquals("my desc", model.getDescription());
    Assert.assertEquals(true, model.getExecutionWindowRequired());
    Assert.assertEquals("my image", model.getImage());
    Assert.assertEquals(new Integer(42), model.getMaxSize());
    Assert.assertEquals("my title", model.getTitle());
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Example 34 with CatalogService

use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.

the class CatalogServiceTest method createWithLabel.

private CatalogService createWithLabel(String label) {
    CatalogService model = new CatalogService();
    model.setLabel(label);
    model.setApprovalRequired(true);
    model.setBaseService("my service");
    URI ewUri = URIUtil.createId(ExecutionWindow.class);
    NamedURI ewId = new NamedURI(ewUri, "ewId");
    model.setDefaultExecutionWindowId(ewId);
    model.setDescription("my desc");
    model.setExecutionWindowRequired(true);
    model.setImage("my image");
    model.setMaxSize(42);
    model.setTitle("my title");
    return model;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Aggregations

CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)34 ServiceDescriptor (com.emc.sa.descriptor.ServiceDescriptor)8 URI (java.net.URI)8 NamedURI (com.emc.storageos.db.client.model.NamedURI)7 CatalogCategory (com.emc.storageos.db.client.model.uimodels.CatalogCategory)7 CatalogServiceField (com.emc.storageos.db.client.model.uimodels.CatalogServiceField)6 Path (javax.ws.rs.Path)6 WorkflowServiceDescriptor (com.emc.sa.catalog.WorkflowServiceDescriptor)5 Produces (javax.ws.rs.Produces)5 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 Test (org.junit.Test)4 BaseModelTest (com.emc.sa.model.BaseModelTest)3 ExecutionState (com.emc.storageos.db.client.model.uimodels.ExecutionState)3 Order (com.emc.storageos.db.client.model.uimodels.Order)3 OrderParameter (com.emc.storageos.db.client.model.uimodels.OrderParameter)3 Consumes (javax.ws.rs.Consumes)3 ModelClient (com.emc.sa.model.dao.ModelClient)2 CatalogServiceAndFields (com.emc.storageos.db.client.model.uimodels.CatalogServiceAndFields)2 ArrayList (java.util.ArrayList)2