@Test public void testAddFilteredUserAttributesToListOfServices() throws Exception { coinUser.addAttribute("service", asList("bar")); Service service1 = RestDataFixture.serviceWithSpEntityId("id-1"); Service service2 = RestDataFixture.serviceWithSpEntityId( "id-2", service -> { service.setId(2l); ARP arp = new ARP(); arp.setNoArp(false); arp.setNoAttrArp(false); arp.setAttributes(ImmutableMap.of("service", asList((Object) "bar"))); service.setArp(arp); }); List<Service> payload = asList(service1, service2); JsonElement jsonElement = createJsonResponse(payload); EnrichJson.forUser(coinUser, STATS_URL).json(jsonElement).forPayload(payload); assertEquals( 0, getServiceFromRoot(jsonElement, 0) .getAsJsonArray(EnrichJson.FILTERED_USER_ATTRIBUTES) .size()); assertEquals( 1, getServiceFromRoot(jsonElement, 1) .getAsJsonArray(EnrichJson.FILTERED_USER_ATTRIBUTES) .size()); }
@Before public void setUp() throws Exception { gson = new GsonBuilder().setExclusionStrategies(new ExcludeJsonIgnore()).create(); coinUser = RestDataFixture.coinUser("ben"); }