AltoNorthboundRouteEndpointproperty implements AltoNorthboundRoute { protected QueryInput prepareInput(String path, Iterator<JsonNode> properties, Iterator<JsonNode> endpoints) { ReadOnlyTransaction rtx = dataBroker.newReadOnlyTransaction(); InstanceIdentifier<ContextTag> ctagIID = getResourceByPath(path, rtx); if(ctagIID == null){ return null; } List<PropertyFilter> listPropertyFilter = constructListPropertyFilter(properties); List<EndpointFilter> listEndpointFilter = constructListEndpointFilter(endpoints); return buildQueryInput(ctagIID, listPropertyFilter, listEndpointFilter); }  void setDataBroker(DataBroker dataBroker); void setMapService(final AltoModelEndpointpropertyService mapService); void init(); void register(AltoNorthboundRouter router); void close(); @Path("{path}") @POST @Consumes({ALTO_ENDPOINTPROPERTY_FILTER}) @Produces({ALTO_ENDPOINTPROPERTY, ALTO_ERROR}) Response getEndpointProperty(@PathParam("path") String path, String content); InstanceIdentifier<ContextTag> getResourceByPath(String path, ReadOnlyTransaction transaction); static final String ALTO_ENDPOINTPROPERTY_FILTER; static final String ALTO_ENDPOINTPROPERTY; static final String FIELD_PROPERTIES; static final String FIELD_ENDPOINTS; static final String IPv4_PREFIX; static final String IPv6_PREFIX; static final String PRIV_PREFIX; }
@Test public void testPrepareInput() { AltoNorthboundRouteEndpointproperty anbreSpy = spy(anbre); InstanceIdentifier<ContextTag> ctagIID = InstanceIdentifier.create(ContextTag.class); JsonNode filterNode = EndpointpropertyRouteChecker.checkJsonSyntax(ENDPOINTPROPERTY_FILTER); JsonNode _properties = filterNode.get(AltoNorthboundRouteEndpointproperty.FIELD_PROPERTIES); JsonNode _endpoints = filterNode.get(AltoNorthboundRouteEndpointproperty.FIELD_ENDPOINTS); doReturn(ctagIID) .when(anbreSpy) .getResourceByPath(eq(PATH), (ReadOnlyTransaction) anyObject()); anbreSpy.setDataBroker(mock(DataBroker.class)); anbreSpy.init(); QueryInput input = anbreSpy.prepareInput(PATH, _properties.elements(), _endpoints.elements()); EndpointpropertyRequest request = (EndpointpropertyRequest)input.getRequest(); EndpointpropertyParams params = request.getEndpointpropertyParams(); List<PropertyFilter> listProperty = ((EndpointpropertyFilterData) params.getFilter()).getEndpointpropertyFilter().getPropertyFilter(); List<EndpointFilter> listEndpoint = ((EndpointpropertyFilterData) params.getFilter()).getEndpointpropertyFilter().getEndpointFilter(); List<PropertyFilter> expectedListProperty = new LinkedList<>(); List<EndpointFilter> expectedListEndpoint = new LinkedList<>(); expectedListProperty.add(new PropertyFilterBuilder() .setProperty(new InputResourceSpecificPropertyBuilder() .setResourceSpecificProperty( new SpecificEndpointProperty(RESOURCE_SPECIFIC_PROPERTY)) .build()) .build() ); expectedListProperty.add(new PropertyFilterBuilder() .setProperty(new InputGlobalPropertyBuilder() .setGlobalProperty( new GlobalEndpointProperty(GLOBAL_PROPERTY)) .build()) .build() ); expectedListEndpoint.add(new EndpointFilterBuilder() .setAddress( new Ipv4Builder() .setIpv4(new Ipv4Address(THE_FIRST_IPv4_ADDRESS)) .build()) .build() ); expectedListEndpoint.add(new EndpointFilterBuilder() .setAddress( new Ipv4Builder() .setIpv4(new Ipv4Address(THE_SECOND_IPv4_ADDRESS)) .build()) .build() ); assertEquals(expectedListProperty, listProperty); assertEquals(expectedListEndpoint, listEndpoint); }