Search in sources :

Example 1 with ModelClient

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"));
}
Also used : InMemoryDbClient(com.emc.sa.model.mock.InMemoryDbClient) ModelClient(com.emc.sa.model.dao.ModelClient) StubCoordinatorClientImpl(com.emc.sa.model.mock.StubCoordinatorClientImpl) Before(org.junit.Before)

Example 2 with ModelClient

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());
}
Also used : ModelClient(com.emc.sa.model.dao.ModelClient) BeforeClass(org.junit.BeforeClass)

Example 3 with ModelClient

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());
}
Also used : ModelClient(com.emc.sa.model.dao.ModelClient) ApprovalRequest(com.emc.storageos.db.client.model.uimodels.ApprovalRequest) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Example 4 with ModelClient

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());
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) ModelClient(com.emc.sa.model.dao.ModelClient) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Example 5 with ModelClient

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());
}
Also used : ModelClient(com.emc.sa.model.dao.ModelClient) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) BaseModelTest(com.emc.sa.model.BaseModelTest) 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