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());
}
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());
}
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());
}
Aggregations