/** Tests region requests. */ @Test public void testRegion() { LegalEntityRegion filter = new LegalEntityRegion(); assertEquals(LegalEntityTest.REGION, filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY)); assertEquals( LegalEntityTest.REGION, filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY_RED_CODE)); assertEquals(Region.class, filter.getFilteredDataType()); filter = new LegalEntityRegion(); filter.setUseName(true); assertEquals( Collections.singleton(LegalEntityTest.REGION.getName()), filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY)); assertEquals( Collections.singleton(LegalEntityTest.REGION.getName()), filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY_RED_CODE)); assertEquals(ParameterizedTypeImpl.of(Set.class, String.class), filter.getFilteredDataType()); filter = new LegalEntityRegion(); filter.setUseCountry(true); assertEquals( Sets.newHashSet(Country.US, Country.CA), filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY)); assertEquals( Sets.newHashSet(Country.US, Country.CA), filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY_RED_CODE)); assertEquals(ParameterizedTypeImpl.of(Set.class, Country.class), filter.getFilteredDataType()); filter = new LegalEntityRegion(); filter.setCountries(Collections.singleton(Country.US)); assertEquals(Sets.newHashSet(Country.US), filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY)); assertEquals( Sets.newHashSet(Country.US), filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY_RED_CODE)); assertEquals(ParameterizedTypeImpl.of(Set.class, Country.class), filter.getFilteredDataType()); filter = new LegalEntityRegion(); filter.setUseCurrency(true); assertEquals( Sets.newHashSet(Currency.CAD, Currency.USD), filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY)); assertEquals( Sets.newHashSet(Currency.CAD, Currency.USD), filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY_RED_CODE)); assertEquals(ParameterizedTypeImpl.of(Set.class, Currency.class), filter.getFilteredDataType()); filter = new LegalEntityRegion(); filter.setCurrencies(Collections.singleton(Currency.USD)); assertEquals( Sets.newHashSet(Currency.USD), filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY)); assertEquals( Sets.newHashSet(Currency.USD), filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY_RED_CODE)); assertEquals(ParameterizedTypeImpl.of(Set.class, Currency.class), filter.getFilteredDataType()); // TODO test builder chaining and currency / country pairs }
/** Tests failure for a region-specific request when the region is null in the legal entity. */ @Test(expectedExceptions = IllegalStateException.class) public void testNullRegionInEntity() { final LegalEntityRegion filter = new LegalEntityRegion(); filter.getFilteredData(new LegalEntity(null, LegalEntityTest.SHORT_NAME, null, null, null)); }