Search in sources :

Example 1 with ObjectMapperTrim

use of org.ligoj.bootstrap.core.json.ObjectMapperTrim in project plugin-prov by ligoj.

the class ProvQuoteInstanceResourceTest method lookupInstanceHighContraints.

/**
 * Advanced case, all requirements.
 */
@Test
public void lookupInstanceHighContraints() throws IOException {
    final QuoteInstanceLookup lookup = new ObjectMapperTrim().readValue(new ObjectMapperTrim().writeValueAsString(qiResource.lookup(subscription, 3, 9, true, VmOs.WINDOWS, null, false, null, "Full Time 12 month")), QuoteInstanceLookup.class);
    final ProvInstancePrice pi = lookup.getPrice();
    Assertions.assertNotNull(pi.getId());
    Assertions.assertEquals("instance9", pi.getType().getName());
    Assertions.assertEquals(4, pi.getType().getCpu().intValue());
    Assertions.assertEquals(16000, pi.getType().getRam().intValue());
    Assertions.assertTrue(pi.getType().getConstant());
    Assertions.assertEquals(2928.0, pi.getCost(), DELTA);
    Assertions.assertEquals(VmOs.WINDOWS, pi.getOs());
    Assertions.assertEquals("1y", pi.getTerm().getName());
    Assertions.assertFalse(pi.getTerm().isEphemeral());
    Assertions.assertFalse(pi.getType().isCustom());
    // Not serialized
    Assertions.assertNull(pi.getType().getNode());
    Assertions.assertNull(pi.getTerm().getNode());
}
Also used : ObjectMapperTrim(org.ligoj.bootstrap.core.json.ObjectMapperTrim) ProvInstancePrice(org.ligoj.app.plugin.prov.model.ProvInstancePrice) AbstractAppTest(org.ligoj.app.AbstractAppTest) Test(org.junit.jupiter.api.Test)

Example 2 with ObjectMapperTrim

use of org.ligoj.bootstrap.core.json.ObjectMapperTrim in project plugin-prov by ligoj.

the class ProvQuoteStorageResourceTest method lookupStorageHighContraints.

/**
 * Advanced case, all requirements.
 */
@Test
public void lookupStorageHighContraints() throws IOException {
    final QuoteStorageLoopup lookup = qsResource.lookup(subscription, 1024, Rate.GOOD, null, null, null).get(0);
    final String asJson = new ObjectMapperTrim().writeValueAsString(lookup);
    Assertions.assertTrue(asJson.startsWith("{\"cost\":215.04,\"price\":{\"id\":"));
    Assertions.assertTrue(asJson.contains("\"cost\":0.0,\"location\":\"region-1\",\"type\":{\"id\":"));
    Assertions.assertTrue(asJson.endsWith("\"name\":\"storage1\",\"description\":\"storageD1\",\"latency\":\"good\"" + ",\"optimized\":\"iops\",\"minimal\":1,\"maximal\":null,\"iops\":200,\"throughput\":60" + ",\"instanceCompatible\":true},\"costGb\":0.21,\"costTransaction\":0.0},\"size\":1024}"));
    // Check the storage result
    assertCSP(lookup);
    Assertions.assertEquals(215.04, lookup.getCost(), DELTA);
}
Also used : ObjectMapperTrim(org.ligoj.bootstrap.core.json.ObjectMapperTrim) AbstractAppTest(org.ligoj.app.AbstractAppTest) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 AbstractAppTest (org.ligoj.app.AbstractAppTest)2 ObjectMapperTrim (org.ligoj.bootstrap.core.json.ObjectMapperTrim)2 ProvInstancePrice (org.ligoj.app.plugin.prov.model.ProvInstancePrice)1