use of com.emc.sa.model.dao.ModelClient in project coprhd-controller by CoprHD.
the class ExecutionEngineImplTest method setUp.
@Before
public void setUp() {
VdcUtil.setDbClient(MockDbClient.create());
modelClient = new ModelClient(new InMemoryDbClient());
coordinatorClient = new StubCoordinatorClientImpl(URI.create("urn:StubCoordinatorClientImpl"));
}
use of com.emc.sa.model.dao.ModelClient in project coprhd-controller by CoprHD.
the class DBClientTestBase method cleanupDb.
@BeforeClass
public static void cleanupDb() {
_logger.info("DBClientTestBase.cleanupDb");
ModelClient modelClient = getModelClient();
modelClient.delete(modelClient.approvalRequests().findAll(DEFAULT_TENANT));
modelClient.delete(modelClient.catalogCategories().findAll(DEFAULT_TENANT));
modelClient.delete(modelClient.catalogServices().findAll());
modelClient.delete(modelClient.catalogServiceFields().findAll());
modelClient.delete(modelClient.datacenters().findAll());
modelClient.delete(modelClient.esxHosts().findAll(DEFAULT_TENANT));
modelClient.delete(modelClient.executionLogs().findAll());
modelClient.delete(modelClient.executionStates().findAll());
modelClient.delete(modelClient.executionTaskLogs().findAll());
modelClient.delete(modelClient.orders().findAll(DEFAULT_TENANT));
modelClient.delete(modelClient.vcenters().findAll(DEFAULT_TENANT));
modelClient.delete(modelClient.virtualMachines().findAll());
}
use of com.emc.sa.model.dao.ModelClient in project coprhd-controller by CoprHD.
the class ApprovalRequestTest method testMultiTenant.
@Test
public void testMultiTenant() throws Exception {
_logger.info("Starting multi tenant ApprovalRequest test");
ModelClient modelClient = getModelClient();
ApprovalRequest ar1 = create("t1", "foo1", ApprovalStatus.PENDING);
modelClient.save(ar1);
ApprovalRequest ar2 = create("t1", "bar2", ApprovalStatus.REJECTED);
modelClient.save(ar2);
ApprovalRequest ar3 = create("t2", "foo3", ApprovalStatus.REJECTED);
modelClient.save(ar3);
ApprovalRequest ar4 = create("t2", "bar4", ApprovalStatus.REJECTED);
modelClient.save(ar4);
ApprovalRequest ar5 = create("t2", "foo5", ApprovalStatus.APPROVED);
modelClient.save(ar5);
ApprovalRequest ar6 = create("t3", "bar6", ApprovalStatus.PENDING);
modelClient.save(ar6);
List<ApprovalRequest> approvalRequests = modelClient.approvalRequests().findAll("t1");
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(2, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findAll("t2");
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(3, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findAll("t3");
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(1, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByLabel("t1", "foo");
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(1, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByLabel("t1", "ba");
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(1, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByLabel("t1", "ab");
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(0, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByLabel("t2", "ba");
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(1, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByLabel("t2", "fo");
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(2, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByLabel("t3", "ba");
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(1, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByLabel("t3", "foo");
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(0, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByApprovalStatus("t1", ApprovalStatus.PENDING);
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(1, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByApprovalStatus("t1", ApprovalStatus.APPROVED);
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(0, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByApprovalStatus("t1", ApprovalStatus.REJECTED);
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(1, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByApprovalStatus("t2", ApprovalStatus.PENDING);
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(0, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByApprovalStatus("t2", ApprovalStatus.APPROVED);
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(1, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByApprovalStatus("t2", ApprovalStatus.REJECTED);
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(2, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByApprovalStatus("t3", ApprovalStatus.PENDING);
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(1, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByApprovalStatus("t3", ApprovalStatus.APPROVED);
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(0, approvalRequests.size());
approvalRequests = modelClient.approvalRequests().findByApprovalStatus("t3", ApprovalStatus.REJECTED);
Assert.assertNotNull(approvalRequests);
Assert.assertEquals(0, approvalRequests.size());
}
use of com.emc.sa.model.dao.ModelClient in project coprhd-controller by CoprHD.
the class CatalogCategoryTest method testPersistObject.
@Test
public void testPersistObject() throws Exception {
_logger.info("Starting persist CatalogCategory test");
ModelClient modelClient = getModelClient();
CatalogCategory model = new CatalogCategory();
model.setId(URIUtil.createId(CatalogCategory.class));
model.setLabel("my label");
URI parentUri = URIUtil.createId(CatalogCategory.class);
NamedURI parentId = new NamedURI(parentUri, "my parent");
model.setCatalogCategoryId(parentId);
model.setDescription("my desc");
model.setImage("my image");
model.setTitle("my title");
model.setTenant(DEFAULT_TENANT);
modelClient.save(model);
model = modelClient.catalogCategories().findById(model.getId());
Assert.assertNotNull(model);
Assert.assertEquals("my label", model.getLabel());
Assert.assertEquals(parentId, model.getCatalogCategoryId());
Assert.assertEquals("my desc", model.getDescription());
Assert.assertEquals("my image", model.getImage());
Assert.assertEquals("my title", model.getTitle());
Assert.assertEquals(DEFAULT_TENANT, model.getTenant());
}
use of com.emc.sa.model.dao.ModelClient in project coprhd-controller by CoprHD.
the class CatalogCategoryTest method testMultiTenant.
@Test
public void testMultiTenant() throws Exception {
_logger.info("Starting multi tenant CatalogCategory test");
ModelClient modelClient = getModelClient();
CatalogCategory root1 = createRoot("t1", "Home1");
modelClient.save(root1);
CatalogCategory root2 = createRoot("t2", "Home2");
modelClient.save(root2);
CatalogCategory root3 = createRoot("t3", "Home3");
modelClient.save(root3);
CatalogCategory root = modelClient.catalogCategories().getRootCategory("t1");
Assert.assertNotNull(root);
Assert.assertEquals("Home1", root.getLabel());
root = modelClient.catalogCategories().getRootCategory("t2");
Assert.assertNotNull(root);
Assert.assertEquals("Home2", root.getLabel());
root = modelClient.catalogCategories().getRootCategory("t3");
Assert.assertNotNull(root);
Assert.assertEquals("Home3", root.getLabel());
}
Aggregations