@Test public void testUpdateIndicatorType() throws Exception { IndicatorType typeA = new IndicatorType("IndicatorTypeA", 100, false); int idA = indicatorTypeStore.save(typeA); typeA = indicatorTypeStore.get(idA); assertEquals(typeA.getName(), "IndicatorTypeA"); typeA.setName("IndicatorTypeB"); indicatorTypeStore.update(typeA); typeA = indicatorTypeStore.get(idA); assertNotNull(typeA); assertEquals(typeA.getName(), "IndicatorTypeB"); }
@Test public void testAddIndicatorType() throws Exception { IndicatorType typeA = new IndicatorType("IndicatorTypeA", 100, false); IndicatorType typeB = new IndicatorType("IndicatorTypeB", 1, false); int idA = indicatorTypeStore.save(typeA); int idB = indicatorTypeStore.save(typeB); typeA = indicatorTypeStore.get(idA); assertNotNull(typeA); assertEquals(idA, typeA.getId()); typeB = indicatorTypeStore.get(idB); assertNotNull(typeB); assertEquals(idB, typeB.getId()); }
@Test public void testGetIndicatorTypeByName() throws Exception { IndicatorType typeA = new IndicatorType("IndicatorTypeA", 100, false); IndicatorType typeB = new IndicatorType("IndicatorTypeB", 1, false); int idA = indicatorTypeStore.save(typeA); int idB = indicatorTypeStore.save(typeB); assertNotNull(indicatorTypeStore.get(idA)); assertNotNull(indicatorTypeStore.get(idB)); typeA = indicatorTypeStore.getByName("IndicatorTypeA"); assertNotNull(typeA); assertEquals(typeA.getId(), idA); IndicatorType typeC = indicatorTypeStore.getByName("IndicatorTypeC"); assertNull(typeC); }
@Test public void testAddIndicatorType() throws Exception { IndicatorType typeA = new IndicatorType("IndicatorTypeA", 100, false); IndicatorType typeB = new IndicatorType("IndicatorTypeB", 1, false); IndicatorType typeC = new IndicatorType("IndicatorTypeA", 100, false); int idA = indicatorTypeStore.save(typeA); int idB = indicatorTypeStore.save(typeB); try { indicatorTypeStore.save(typeC); fail("Expected unique constraint exception"); } catch (Exception ex) { } typeA = indicatorTypeStore.get(idA); assertNotNull(typeA); assertEquals(idA, typeA.getId()); typeB = indicatorTypeStore.get(idB); assertNotNull(typeB); assertEquals(idB, typeB.getId()); }