Search in sources :

Example 1 with DeleteDomainRequest

use of com.amazonaws.services.simpledb.model.DeleteDomainRequest in project simplejpa by appoxy.

the class UtilTests method deleteAll.

@After
public void deleteAll() throws AmazonClientException {
    EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
    AmazonSimpleDB db = em.getSimpleDb();
    String domainName = em.getDomainName(MyTestObject.class);
    db.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
    domainName = em.getDomainName(MyTestObject2.class);
    db.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
    domainName = em.getDomainName(MyInheritanceObject1.class);
    db.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
    em.close();
}
Also used : DeleteDomainRequest(com.amazonaws.services.simpledb.model.DeleteDomainRequest) AmazonSimpleDB(com.amazonaws.services.simpledb.AmazonSimpleDB)

Example 2 with DeleteDomainRequest

use of com.amazonaws.services.simpledb.model.DeleteDomainRequest in project simplejpa by appoxy.

the class DomainHelperTests method selectItemsTests.

@Test
public void selectItemsTests() {
    EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
    AmazonSimpleDB sdbClient = em.getSimpleDb();
    String domainName = "simplejpa-domainhelper-tests";
    sdbClient.createDomain(new CreateDomainRequest().withDomainName(domainName));
    try {
        for (int i = 0; i < 10; i++) {
            sdbClient.putAttributes(new PutAttributesRequest().withItemName("thing" + i).withDomainName(domainName).withAttributes(new ReplaceableAttribute("name", "value", true)));
        }
        SelectResult result = DomainHelper.selectItems(sdbClient, String.format("select * from `%s` LIMIT 3", domainName), null);
        Assert.assertEquals(3, result.getItems().size());
        Assert.assertNotNull(result.getNextToken());
        result = DomainHelper.selectItems(sdbClient, String.format("select * from `%s` LIMIT 3", domainName), result.getNextToken());
        Assert.assertEquals(3, result.getItems().size());
        Assert.assertNotNull(result.getNextToken());
        result = DomainHelper.selectItems(sdbClient, String.format("select * from `%s` LIMIT 3", domainName), result.getNextToken());
        Assert.assertEquals(3, result.getItems().size());
        Assert.assertNotNull(result.getNextToken());
        result = DomainHelper.selectItems(sdbClient, String.format("select * from `%s` LIMIT 3", domainName), result.getNextToken());
        Assert.assertEquals(1, result.getItems().size());
        Assert.assertNull(result.getNextToken());
    } finally {
        sdbClient.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
    }
}
Also used : SelectResult(com.amazonaws.services.simpledb.model.SelectResult) DeleteDomainRequest(com.amazonaws.services.simpledb.model.DeleteDomainRequest) AmazonSimpleDB(com.amazonaws.services.simpledb.AmazonSimpleDB) CreateDomainRequest(com.amazonaws.services.simpledb.model.CreateDomainRequest) PutAttributesRequest(com.amazonaws.services.simpledb.model.PutAttributesRequest) ReplaceableAttribute(com.amazonaws.services.simpledb.model.ReplaceableAttribute) Test(org.junit.Test)

Example 3 with DeleteDomainRequest

use of com.amazonaws.services.simpledb.model.DeleteDomainRequest in project simplejpa by appoxy.

the class DomainHelperTests method selectItemsWithWhereTests.

@Test
public void selectItemsWithWhereTests() {
    EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
    AmazonSimpleDB sdbClient = em.getSimpleDb();
    String domainName = "simplejpa-domainhelper-tests";
    sdbClient.createDomain(new CreateDomainRequest().withDomainName(domainName));
    try {
        for (int i = 0; i < 10; i++) {
            sdbClient.putAttributes(new PutAttributesRequest().withItemName("thing" + i).withDomainName(domainName).withAttributes(new ReplaceableAttribute("name", "value", true)));
        }
        SelectResult result = DomainHelper.selectItems(sdbClient, domainName, "name = 'value' LIMIT 3", null);
        Assert.assertEquals(3, result.getItems().size());
        Assert.assertNotNull(result.getNextToken());
        result = DomainHelper.selectItems(sdbClient, domainName, "name = 'value' LIMIT 3", result.getNextToken());
        Assert.assertEquals(3, result.getItems().size());
        Assert.assertNotNull(result.getNextToken());
        result = DomainHelper.selectItems(sdbClient, domainName, "name = 'value' LIMIT 3", result.getNextToken());
        Assert.assertEquals(3, result.getItems().size());
        Assert.assertNotNull(result.getNextToken());
        result = DomainHelper.selectItems(sdbClient, domainName, "name = 'value' LIMIT 3", result.getNextToken());
        Assert.assertEquals(1, result.getItems().size());
        Assert.assertNull(result.getNextToken());
    } finally {
        sdbClient.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
    }
}
Also used : SelectResult(com.amazonaws.services.simpledb.model.SelectResult) DeleteDomainRequest(com.amazonaws.services.simpledb.model.DeleteDomainRequest) AmazonSimpleDB(com.amazonaws.services.simpledb.AmazonSimpleDB) CreateDomainRequest(com.amazonaws.services.simpledb.model.CreateDomainRequest) PutAttributesRequest(com.amazonaws.services.simpledb.model.PutAttributesRequest) ReplaceableAttribute(com.amazonaws.services.simpledb.model.ReplaceableAttribute) Test(org.junit.Test)

Example 4 with DeleteDomainRequest

use of com.amazonaws.services.simpledb.model.DeleteDomainRequest in project simplejpa by appoxy.

the class DomainHelperTests method listAllItemsTests.

@Test
public void listAllItemsTests() {
    EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
    AmazonSimpleDB sdbClient = em.getSimpleDb();
    String domainName = "simplejpa-domainhelper-tests";
    sdbClient.createDomain(new CreateDomainRequest().withDomainName(domainName));
    try {
        for (int i = 0; i < 3; i++) {
            sdbClient.putAttributes(new PutAttributesRequest().withItemName("thing" + i).withDomainName(domainName).withAttributes(new ReplaceableAttribute("name", "value", true)));
        }
        List<Item> items = DomainHelper.listAllItems(sdbClient, domainName);
        Assert.assertEquals(3, items.size());
    } finally {
        sdbClient.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
    }
}
Also used : Item(com.amazonaws.services.simpledb.model.Item) DeleteDomainRequest(com.amazonaws.services.simpledb.model.DeleteDomainRequest) AmazonSimpleDB(com.amazonaws.services.simpledb.AmazonSimpleDB) CreateDomainRequest(com.amazonaws.services.simpledb.model.CreateDomainRequest) PutAttributesRequest(com.amazonaws.services.simpledb.model.PutAttributesRequest) ReplaceableAttribute(com.amazonaws.services.simpledb.model.ReplaceableAttribute) Test(org.junit.Test)

Example 5 with DeleteDomainRequest

use of com.amazonaws.services.simpledb.model.DeleteDomainRequest in project simplejpa by appoxy.

the class DomainHelperTests method findByIdTest.

@Test
public void findByIdTest() {
    EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
    AmazonSimpleDB sdbClient = em.getSimpleDb();
    String domainName = "simplejpa-domainhelper-tests";
    sdbClient.createDomain(new CreateDomainRequest().withDomainName(domainName));
    try {
        Assert.assertNull(DomainHelper.findItemById(sdbClient, domainName, "noexist"));
        sdbClient.putAttributes(new PutAttributesRequest().withItemName("exist").withDomainName(domainName).withAttributes(new ReplaceableAttribute("name", "value", true)));
        Assert.assertNotNull(DomainHelper.findItemById(sdbClient, domainName, "exist"));
    } finally {
        sdbClient.deleteDomain(new DeleteDomainRequest().withDomainName(domainName));
    }
}
Also used : DeleteDomainRequest(com.amazonaws.services.simpledb.model.DeleteDomainRequest) AmazonSimpleDB(com.amazonaws.services.simpledb.AmazonSimpleDB) CreateDomainRequest(com.amazonaws.services.simpledb.model.CreateDomainRequest) PutAttributesRequest(com.amazonaws.services.simpledb.model.PutAttributesRequest) ReplaceableAttribute(com.amazonaws.services.simpledb.model.ReplaceableAttribute) Test(org.junit.Test)

Aggregations

DeleteDomainRequest (com.amazonaws.services.simpledb.model.DeleteDomainRequest)6 AmazonSimpleDB (com.amazonaws.services.simpledb.AmazonSimpleDB)5 CreateDomainRequest (com.amazonaws.services.simpledb.model.CreateDomainRequest)4 PutAttributesRequest (com.amazonaws.services.simpledb.model.PutAttributesRequest)4 ReplaceableAttribute (com.amazonaws.services.simpledb.model.ReplaceableAttribute)4 Test (org.junit.Test)4 SelectResult (com.amazonaws.services.simpledb.model.SelectResult)2 Item (com.amazonaws.services.simpledb.model.Item)1