@Test public void noConditions() { final EmsGrantData source = new EmsGrantData(); final ConditionData target = new ConditionData(); source.setConditionGeo(Collections.<String>emptyList()); populator.populate(source, target); assertNull(target.getType()); assertTrue(target.getProperties() == null || target.getProperties().isEmpty()); }
/* * Errors of this kind are to be filtered by ProductEntitlementValidateInterceptor and server side of EMS */ @Test public void trailingSlash() { final EmsGrantData source = new EmsGrantData(); final ConditionData target = new ConditionData(); final String location = "Deutschland/"; source.setConditionGeo(Arrays.asList(location)); populator.populate(source, target); assertEquals("geo", target.getType()); assertEquals(1, target.getProperties().size()); assertEquals(location, target.getProperty("geoPath")); }
/* * Errors of this kind are to be filtered by ProductEntitlementValidateInterceptor and server side of EMS */ @Test public void commasInPathItem() { final EmsGrantData source = new EmsGrantData(); final ConditionData target = new ConditionData(); final String location = "Germany/Bayern/Munich,England/Merseyside/Liverpool"; source.setConditionGeo(Arrays.asList(location)); populator.populate(source, target); assertEquals("geo", target.getType()); assertEquals(1, target.getProperties().size()); assertEquals(location, target.getProperty("geoPath")); }
/* * Errors of this kind are to be filtered by ProductEntitlementValidateInterceptor and server side of EMS */ @Test public void missingRegion() { final EmsGrantData source = new EmsGrantData(); final ConditionData target = new ConditionData(); final String location = "England//Liverpool"; source.setConditionGeo(Arrays.asList(location)); populator.populate(source, target); assertEquals("geo", target.getType()); assertEquals(1, target.getProperties().size()); assertEquals(location, target.getProperty("geoPath")); }
/* * Errors of this kind are to be filtered by ProductEntitlementValidateInterceptor and server side of EMS */ @Test public void tooManyLevels() { final EmsGrantData source = new EmsGrantData(); final ConditionData target = new ConditionData(); final String location = "Россия/Омская область/Тарский район/Тара"; source.setConditionGeo(Arrays.asList(location)); populator.populate(source, target); assertEquals("geo", target.getType()); assertEquals(1, target.getProperties().size()); assertEquals(location, target.getProperty("geoPath")); }
@Test public void multiLocations() { final EmsGrantData source = new EmsGrantData(); final ConditionData target = new ConditionData(); final String location1 = "Deutschland/Bayern/München"; final String location2 = "Россия/Омская область/Тара"; source.setConditionGeo(Arrays.asList(location1, location2)); populator.populate(source, target); assertEquals("geo", target.getType()); assertEquals(1, target.getProperties().size()); assertEquals(location1 + ',' + location2, target.getProperty("geoPath")); }