/** Tests sector requests. */
 @Test
 public void testSector() {
   LegalEntitySector filter = new LegalEntitySector();
   assertEquals(LegalEntityTest.SECTOR, filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY));
   assertEquals(
       LegalEntityTest.SECTOR, filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY_RED_CODE));
   assertEquals(Sector.class, filter.getFilteredDataType());
   filter = new LegalEntitySector();
   filter.setUseSectorName(true);
   assertEquals(
       Collections.singleton(LegalEntityTest.SECTOR.getName()),
       filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY));
   assertEquals(ParameterizedTypeImpl.of(Set.class, String.class), filter.getFilteredDataType());
   filter = new LegalEntitySector();
   filter.setClassifications(Collections.singleton(GICSCode.NAME));
   filter.setClassificationValueTypes(Collections.singleton(GICSCode.class));
   assertEquals(
       Collections.singleton(GICSCode.of(10203040)),
       filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY));
   assertEquals(ParameterizedTypeImpl.of(Set.class, GICSCode.class), filter.getFilteredDataType());
   filter = new LegalEntitySector();
   filter.setClassifications(Collections.singleton(ICBCode.NAME));
   filter.setClassificationValueTypes(Collections.singleton(ICBCode.class));
   assertEquals(
       Collections.singleton(ICBCode.of("1020")),
       filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY));
   assertEquals(ParameterizedTypeImpl.of(Set.class, ICBCode.class), filter.getFilteredDataType());
   filter = new LegalEntitySector();
   filter.setClassifications(ImmutableSet.of(GICSCode.NAME, ICBCode.NAME));
   filter.setClassificationValueTypes(ImmutableSet.of(GICSCode.class, ICBCode.class));
   assertEquals(
       ImmutableSet.of(GICSCode.of(10203040), ICBCode.of("1020")),
       filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY));
   assertEquals(
       ParameterizedTypeImpl.of(Set.class, VariantType.either(GICSCode.class, ICBCode.class)),
       filter.getFilteredDataType());
   filter = new LegalEntitySector();
   filter.setUseClassificationName(true);
   assertTrue(filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY) instanceof Set);
   assertTrue(((Set<?>) filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY)).isEmpty());
   assertTrue(filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY_RED_CODE) instanceof Set);
   assertTrue(((Set<?>) filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY_RED_CODE)).isEmpty());
   assertEquals(ParameterizedTypeImpl.of(Set.class, Object.class), filter.getFilteredDataType());
 }
 /** Tests combining rating and sector. */
 @Test
 public void testRatingAndSector() {
   final LegalEntityCombiningFilter filter = new LegalEntityCombiningFilter();
   final Set<LegalEntityFilter<LegalEntity>> underlyingFilters = new HashSet<>();
   final LegalEntityCreditRatings ratingsFilter = new LegalEntityCreditRatings();
   ratingsFilter.setPerAgencyRatings(Collections.singleton("S&P"));
   underlyingFilters.add(ratingsFilter);
   final LegalEntitySector sectorFilter = new LegalEntitySector();
   sectorFilter.setUseSectorName(true);
   underlyingFilters.add(sectorFilter);
   underlyingFilters.add(new LegalEntityCombiningFilter());
   filter.setFiltersToUse(underlyingFilters);
   final Set<Object> expected = new HashSet<>();
   expected.add(LegalEntityTest.SECTOR.getName());
   expected.add(Pair.of("S&P", "A"));
   assertEquals(expected, filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY));
   assertEquals(expected, filter.getFilteredData(LegalEntityTest.LEGAL_ENTITY_RED_CODE));
   assertEquals(
       ParameterizedTypeImpl.of(
           Set.class,
           VariantType.either(
               String.class, ParameterizedTypeImpl.of(Pair.class, String.class, String.class))),
       filter.getFilteredDataType());
 }