org.testobject.rest.api.resource.DeviceDescriptorsResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of testobject-java-api Show documentation
Show all versions of testobject-java-api Show documentation
java wrapper for testobject's java apis
package org.testobject.rest.api.resource;
import org.testobject.rest.api.model.DeviceDescriptor;
import org.testobject.rest.api.model.DeviceDescriptor.DeviceContainer;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.stream.Collectors;
public class DeviceDescriptorsResource {
private final WebTarget target;
public DeviceDescriptorsResource(WebTarget target) {
this.target = target;
}
public List getAvailableDeviceDescriptorIds() {
return target
.path("descriptors")
.path("availableDescriptors")
.request(MediaType.APPLICATION_JSON)
.get(new GenericType>() {
});
}
public List getAvailableDeviceDescriptors() {
List deviceDescriptors = target
.path("descriptors")
.request(MediaType.APPLICATION_JSON)
.get(new GenericType>() {
});
return filterAvailable(deviceDescriptors);
}
private List filterAvailable(List descriptors) {
List availableDescriptorIds = getAvailableDeviceDescriptorIds();
return descriptors.stream()
.filter(deviceContainer -> availableDescriptorIds.contains(deviceContainer.id))
.map(deviceContainer -> new DeviceDescriptor(deviceContainer, true))
.collect(Collectors.toList());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy