Search in sources :

Example 11 with ModelClient

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

the class VirtualMachineTest method testPersistObject.

@Test
public void testPersistObject() throws Exception {
    _logger.info("Starting persist VirtualMachine test");
    ModelClient modelClient = getModelClient();
    VirtualMachine model = new VirtualMachine();
    model.setId(URIUtil.createId(VirtualMachine.class));
    model.setLabel("foo");
    model.setRunning(false);
    model.setTemplate(true);
    URI datacenterUri = URIUtil.createId(VcenterDataCenter.class);
    NamedURI datacenterId = new NamedURI(datacenterUri, "dc1");
    model.setDatacenterId(datacenterId);
    modelClient.save(model);
    model = modelClient.virtualMachines().findById(model.getId());
    Assert.assertNotNull(model);
    Assert.assertEquals("foo", model.getLabel());
    Assert.assertEquals(false, model.getRunning());
    Assert.assertEquals(true, model.getTemplate());
    Assert.assertEquals(datacenterId, model.getDatacenterId());
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) ModelClient(com.emc.sa.model.dao.ModelClient) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) VirtualMachine(com.emc.storageos.db.client.model.uimodels.VirtualMachine) Test(org.junit.Test)

Example 12 with ModelClient

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

the class DBClientTestBase method createModelClient.

protected static ModelClient createModelClient() {
    BourneDbClient bourneDbClient = new BourneDbClient();
    bourneDbClient.setDbClient(createDbClient());
    bourneDbClient.init();
    ModelClient modelClient = new ModelClient(bourneDbClient);
    return modelClient;
}
Also used : BourneDbClient(com.emc.sa.model.dao.BourneDbClient) ModelClient(com.emc.sa.model.dao.ModelClient)

Example 13 with ModelClient

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

the class CatalogCategoryTest method testReparentCategory.

@Test
public void testReparentCategory() throws Exception {
    ModelClient modelClient = getModelClient();
    CatalogCategory parent1 = createCategory("Parent1");
    modelClient.save(parent1);
    CatalogCategory parent2 = createCategory("Parent2");
    modelClient.save(parent2);
    CatalogCategory child = createCategory("Child");
    setParent(parent1, child);
    modelClient.save(child);
    List<CatalogCategory> parent1Children = modelClient.catalogCategories().findSubCatalogCategories(parent1.getId());
    Assert.assertEquals(1, parent1Children.size());
    Assert.assertEquals(child.getId(), parent1Children.get(0).getId());
    List<CatalogCategory> parent2Children = modelClient.catalogCategories().findSubCatalogCategories(parent2.getId());
    Assert.assertEquals(0, parent2Children.size());
    setParent(parent2, child);
    modelClient.save(child);
    parent1Children = modelClient.catalogCategories().findSubCatalogCategories(parent1.getId());
    Assert.assertEquals(0, parent1Children.size());
    parent2Children = modelClient.catalogCategories().findSubCatalogCategories(parent2.getId());
    Assert.assertEquals(1, parent2Children.size());
    Assert.assertEquals(child.getId(), parent2Children.get(0).getId());
}
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)

Example 14 with ModelClient

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

the class CatalogCategoryTest method testFindSubCatalogCategories.

@Test
public void testFindSubCatalogCategories() {
    _logger.info("Starting FindByLabel test");
    ModelClient modelClient = getModelClient();
    CatalogCategory root = createWithLabel("rooty");
    CatalogCategory catalogCategory = createWithLabel("asdf");
    catalogCategory.setCatalogCategoryId(new NamedURI(root.getId(), root.getLabel()));
    modelClient.save(catalogCategory);
    catalogCategory = createWithLabel("asdf2");
    catalogCategory.setCatalogCategoryId(new NamedURI(root.getId(), root.getLabel()));
    modelClient.save(catalogCategory);
    catalogCategory = createWithLabel("asdf3");
    catalogCategory.setCatalogCategoryId(new NamedURI(root.getId(), root.getLabel()));
    modelClient.save(catalogCategory);
    modelClient.save(root);
    List<CatalogCategory> subCatalogCategories = modelClient.catalogCategories().findSubCatalogCategories(root.getId());
    Assert.assertNotNull(subCatalogCategories);
    Assert.assertEquals(3, subCatalogCategories.size());
}
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) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Example 15 with ModelClient

use of com.emc.sa.model.dao.ModelClient 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)

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