Search in sources :

Example 16 with ModelClient

use of com.emc.sa.model.dao.ModelClient in project coprhd-controller by CoprHD.

the class ExecutionWindowTest method testMultiTenant.

@Test
public void testMultiTenant() throws Exception {
    _logger.info("Starting multi tenant ExecutionWindow test");
    ModelClient modelClient = getModelClient();
    ExecutionWindow ew1 = create("t1", "foo1");
    modelClient.save(ew1);
    ExecutionWindow ew2 = create("t1", "bar2");
    modelClient.save(ew2);
    ExecutionWindow ew3 = create("t2", "foo3");
    modelClient.save(ew3);
    ExecutionWindow ew4 = create("t2", "bar4");
    modelClient.save(ew4);
    ExecutionWindow ew5 = create("t2", "foo5");
    modelClient.save(ew5);
    ExecutionWindow ew6 = create("t3", "bar6");
    modelClient.save(ew6);
    List<ExecutionWindow> executionWindows = modelClient.executionWindows().findAll("t1");
    Assert.assertNotNull(executionWindows);
    Assert.assertEquals(2, executionWindows.size());
    executionWindows = modelClient.executionWindows().findAll("t2");
    Assert.assertNotNull(executionWindows);
    Assert.assertEquals(3, executionWindows.size());
    executionWindows = modelClient.executionWindows().findAll("t3");
    Assert.assertNotNull(executionWindows);
    Assert.assertEquals(1, executionWindows.size());
}
Also used : ExecutionWindow(com.emc.storageos.db.client.model.uimodels.ExecutionWindow) ModelClient(com.emc.sa.model.dao.ModelClient) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Example 17 with ModelClient

use of com.emc.sa.model.dao.ModelClient in project coprhd-controller by CoprHD.

the class OrderTest method testFindScheduledByExecutionWindow.

@Test
public void testFindScheduledByExecutionWindow() {
    _logger.info("Starting save Order and Execution State test");
    ModelClient modelClient = getModelClient();
    NamedURI ewId1 = new NamedURI(URIUtil.createId(ExecutionWindow.class), "ewId1");
    NamedURI ewId2 = new NamedURI(URIUtil.createId(ExecutionWindow.class), "ewId2");
    Order o1 = createOrder(OrderStatus.PENDING);
    o1.setExecutionWindowId(ewId1);
    modelClient.save(o1);
    Order o2 = createOrder(OrderStatus.SCHEDULED);
    o2.setExecutionWindowId(ewId2);
    modelClient.save(o2);
    Order o3 = createOrder(OrderStatus.SCHEDULED);
    o3.setExecutionWindowId(ewId1);
    modelClient.save(o3);
    List<Order> orders = modelClient.orders().findScheduledByExecutionWindow(ewId2.getURI().toString());
    Assert.assertNotNull(orders);
    Assert.assertEquals(1, orders.size());
    orders = modelClient.orders().findScheduledByExecutionWindow(ewId1.getURI().toString());
    Assert.assertNotNull(orders);
    Assert.assertEquals(1, orders.size());
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) NamedURI(com.emc.storageos.db.client.model.NamedURI) ExecutionWindow(com.emc.storageos.db.client.model.uimodels.ExecutionWindow) ModelClient(com.emc.sa.model.dao.ModelClient) Test(org.junit.Test) BaseModelTest(com.emc.sa.model.BaseModelTest)

Example 18 with ModelClient

use of com.emc.sa.model.dao.ModelClient in project coprhd-controller by CoprHD.

the class SortedIndexTest method testSorting.

@Test
public void testSorting() {
    Order o1 = createOrder(OrderStatus.PENDING);
    ModelClient modelClient = getModelClient();
    modelClient.save(o1);
    OrderParameter op1 = createOrderParameter("op1", "op1Value", 2);
    op1.setOrderId(o1.getId());
    modelClient.save(op1);
    OrderParameter op2 = createOrderParameter("op2", "op2Value", 1);
    op2.setOrderId(o1.getId());
    modelClient.save(op2);
    OrderParameter op3 = createOrderParameter("op3", "op3Value", 3);
    op3.setOrderId(o1.getId());
    modelClient.save(op3);
    List<OrderParameter> orderParameters = modelClient.orderParameters().findByOrderId(o1.getId());
    Assert.assertNotNull(orderParameters);
    Assert.assertEquals(3, orderParameters.size());
    Assert.assertEquals(op2.getLabel(), orderParameters.get(0).getLabel());
    Assert.assertEquals(op1.getLabel(), orderParameters.get(1).getLabel());
    Assert.assertEquals(op3.getLabel(), orderParameters.get(2).getLabel());
    SortedIndexUtils.moveDown(op1, modelClient);
    orderParameters = modelClient.orderParameters().findByOrderId(o1.getId());
    Assert.assertNotNull(orderParameters);
    Assert.assertEquals(3, orderParameters.size());
    Assert.assertEquals(op2.getLabel(), orderParameters.get(0).getLabel());
    Assert.assertEquals(op3.getLabel(), orderParameters.get(1).getLabel());
    Assert.assertEquals(op1.getLabel(), orderParameters.get(2).getLabel());
    SortedIndexUtils.moveUp(op3, modelClient);
    orderParameters = modelClient.orderParameters().findByOrderId(o1.getId());
    Assert.assertNotNull(orderParameters);
    Assert.assertEquals(3, orderParameters.size());
    Assert.assertEquals(op3.getLabel(), orderParameters.get(0).getLabel());
    Assert.assertEquals(op2.getLabel(), orderParameters.get(1).getLabel());
    Assert.assertEquals(op1.getLabel(), orderParameters.get(2).getLabel());
    OrderParameter op4 = createOrderParameter("op4", "op4Value", null);
    op4.setOrderId(o1.getId());
    modelClient.save(op4);
    orderParameters = modelClient.orderParameters().findByOrderId(o1.getId());
    Assert.assertNotNull(orderParameters);
    Assert.assertEquals(4, orderParameters.size());
    Assert.assertEquals(op3.getLabel(), orderParameters.get(0).getLabel());
    Assert.assertEquals(op2.getLabel(), orderParameters.get(1).getLabel());
    Assert.assertEquals(op1.getLabel(), orderParameters.get(2).getLabel());
    Assert.assertEquals(op4.getLabel(), orderParameters.get(3).getLabel());
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter) ModelClient(com.emc.sa.model.dao.ModelClient) Test(org.junit.Test)

Aggregations

ModelClient (com.emc.sa.model.dao.ModelClient)18 Test (org.junit.Test)15 BaseModelTest (com.emc.sa.model.BaseModelTest)12 NamedURI (com.emc.storageos.db.client.model.NamedURI)8 CatalogCategory (com.emc.storageos.db.client.model.uimodels.CatalogCategory)7 Order (com.emc.storageos.db.client.model.uimodels.Order)4 URI (java.net.URI)3 CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)2 ExecutionWindow (com.emc.storageos.db.client.model.uimodels.ExecutionWindow)2 VirtualMachine (com.emc.storageos.db.client.model.uimodels.VirtualMachine)2 BourneDbClient (com.emc.sa.model.dao.BourneDbClient)1 InMemoryDbClient (com.emc.sa.model.mock.InMemoryDbClient)1 StubCoordinatorClientImpl (com.emc.sa.model.mock.StubCoordinatorClientImpl)1 Vcenter (com.emc.storageos.db.client.model.Vcenter)1 VcenterDataCenter (com.emc.storageos.db.client.model.VcenterDataCenter)1 ApprovalRequest (com.emc.storageos.db.client.model.uimodels.ApprovalRequest)1 ExecutionLog (com.emc.storageos.db.client.model.uimodels.ExecutionLog)1 ExecutionState (com.emc.storageos.db.client.model.uimodels.ExecutionState)1 OrderParameter (com.emc.storageos.db.client.model.uimodels.OrderParameter)1 Date (java.util.Date)1