Search in sources :

Example 1 with ReductionKeyEdgeResponseDTO

use of org.opennms.web.rest.v2.bsm.model.edge.ReductionKeyEdgeResponseDTO in project opennms by OpenNMS.

the class ReductionKeyEdgeResponseDTOMarshalTest method data.

@Parameterized.Parameters
public static Collection<Object[]> data() throws IOException {
    MapFunctionDTO mapFunctionDTO = new MapFunctionDTO();
    mapFunctionDTO.getProperties().put("key1", "value1");
    mapFunctionDTO.setType("SetTo");
    ReductionKeyEdgeResponseDTO edge = new ReductionKeyEdgeResponseDTO();
    edge.setLocation(new ResourceLocation(ApiVersion.Version2, "business-services", "edges", "1"));
    edge.setReductionKey("my-custom-reduction-key");
    edge.setOperationalStatus(Status.WARNING);
    edge.setMapFunction(mapFunctionDTO);
    edge.setId(1);
    edge.setWeight(17);
    edge.setFriendlyName("reduction-key-friendly-name");
    return Arrays.asList(new Object[][] { { ReductionKeyEdgeResponseDTO.class, edge, "{" + "  \"id\" : 1," + "  \"operational-status\" : \"WARNING\"," + "  \"map-function\" : {" + "       \"type\" : \"SetTo\"," + "       \"properties\" : {" + "           \"key1\" : \"value1\"" + "       }" + "   }," + "  \"location\" : \"/api/v2/business-services/edges/1\"," + "  \"reduction-keys\" : [" + "       \"my-custom-reduction-key\"" + "   ]," + "  \"weight\" : 17," + "  \"friendly-name\" : \"reduction-key-friendly-name\"," + "}", "<reduction-key-edge>\n" + "   <id>1</id>\n" + "   <operational-status>WARNING</operational-status>\n" + "   <map-function>\n" + "      <type>SetTo</type>\n" + "      <properties>\n" + "         <entry>\n" + "            <key>key1</key>\n" + "            <value>value1</value>\n" + "         </entry>\n" + "      </properties>\n" + "   </map-function>\n" + "   <location>/api/v2/business-services/edges/1</location>\n" + "   <reduction-keys>\n" + "      <reduction-key>my-custom-reduction-key</reduction-key>\n" + "   </reduction-keys>\n" + "   <weight>17</weight>\n" + "   <friendly-name>reduction-key-friendly-name</friendly-name>\n" + "</reduction-key-edge>" } });
}
Also used : MapFunctionDTO(org.opennms.web.rest.v2.bsm.model.MapFunctionDTO) ResourceLocation(org.opennms.web.rest.api.ResourceLocation)

Example 2 with ReductionKeyEdgeResponseDTO

use of org.opennms.web.rest.v2.bsm.model.edge.ReductionKeyEdgeResponseDTO in project opennms by OpenNMS.

the class BsmTestUtils method toResponseDTO.

public static ReductionKeyEdgeResponseDTO toResponseDTO(SingleReductionKeyEdgeEntity input) {
    ReductionKeyEdgeResponseDTO edge = new ReductionKeyEdgeResponseDTO();
    edge.setLocation(ResourceLocationFactory.createBusinessServiceEdgeLocation(input.getBusinessService().getId(), input.getId()));
    edge.setReductionKeys(input.getReductionKeys());
    edge.setReductionKey(input.getReductionKey());
    edge.setMapFunction(transform(input.getMapFunction()));
    edge.setId(input.getId());
    edge.setWeight(input.getWeight());
    edge.setFriendlyName(input.getFriendlyName());
    // we assume INDETERMINATE
    edge.setOperationalStatus(Status.INDETERMINATE);
    return edge;
}
Also used : ReductionKeyEdgeResponseDTO(org.opennms.web.rest.v2.bsm.model.edge.ReductionKeyEdgeResponseDTO)

Example 3 with ReductionKeyEdgeResponseDTO

use of org.opennms.web.rest.v2.bsm.model.edge.ReductionKeyEdgeResponseDTO in project opennms by OpenNMS.

the class BusinessServiceResponseDTOMarshalTest method createReductionKeyEdgeResponse.

private static ReductionKeyEdgeResponseDTO createReductionKeyEdgeResponse(long id, String reductionKey, MapFunctionDTO mapFunctionDTO, Status status, ResourceLocation location, String friendlyName) {
    ReductionKeyEdgeResponseDTO responseDTO = new ReductionKeyEdgeResponseDTO();
    responseDTO.setOperationalStatus(status);
    responseDTO.setId(id);
    responseDTO.setWeight(9);
    responseDTO.setLocation(location);
    responseDTO.setReductionKeys(Sets.newHashSet(reductionKey));
    responseDTO.setMapFunction(mapFunctionDTO);
    responseDTO.setFriendlyName(friendlyName);
    return responseDTO;
}
Also used : ReductionKeyEdgeResponseDTO(org.opennms.web.rest.v2.bsm.model.edge.ReductionKeyEdgeResponseDTO)

Example 4 with ReductionKeyEdgeResponseDTO

use of org.opennms.web.rest.v2.bsm.model.edge.ReductionKeyEdgeResponseDTO in project opennms by OpenNMS.

the class BusinessServiceRestService method transform.

private ReductionKeyEdgeResponseDTO transform(ReductionKeyEdge edge) {
    final ReductionKeyEdgeResponseDTO response = new ReductionKeyEdgeResponseDTO();
    response.setId(edge.getId());
    response.setOperationalStatus(edge.getOperationalStatus());
    response.setReductionKey(edge.getReductionKey());
    response.setLocation(ResourceLocationFactory.createBusinessServiceEdgeLocation(edge.getSource().getId(), edge.getId()));
    response.setReductionKeys(edge.getReductionKeys());
    response.setMapFunction(transform(edge.getMapFunction()));
    response.setWeight(edge.getWeight());
    response.setFriendlyName(edge.getFriendlyName());
    return response;
}
Also used : ReductionKeyEdgeResponseDTO(org.opennms.web.rest.v2.bsm.model.edge.ReductionKeyEdgeResponseDTO)

Aggregations

ReductionKeyEdgeResponseDTO (org.opennms.web.rest.v2.bsm.model.edge.ReductionKeyEdgeResponseDTO)3 ResourceLocation (org.opennms.web.rest.api.ResourceLocation)1 MapFunctionDTO (org.opennms.web.rest.v2.bsm.model.MapFunctionDTO)1