com.applitools.eyes.selenium.universal.mapper.TFloatingRegionMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eyes-selenium-java5 Show documentation
Show all versions of eyes-selenium-java5 Show documentation
Applitools Eyes SDK for Selenium Java WebDriver
package com.applitools.eyes.selenium.universal.mapper;
import java.util.List;
import java.util.stream.Collectors;
import com.applitools.eyes.fluent.FloatingRegionByRectangle;
import com.applitools.eyes.fluent.GetRegion;
import com.applitools.eyes.selenium.fluent.FloatingRegionByElement;
import com.applitools.eyes.selenium.fluent.FloatingRegionBySelector;
import com.applitools.eyes.selenium.fluent.FloatingRegionByTargetPathLocator;
import com.applitools.eyes.selenium.universal.dto.*;
import com.applitools.eyes.universal.dto.*;
import com.applitools.eyes.universal.mapper.RectangleRegionMapper;
import com.applitools.eyes.visualgrid.model.IGetFloatingRegionOffsets;
/**
* floating region mapper
*/
public class TFloatingRegionMapper {
public static TFloatingRegion toTFloatingRegionDto(GetRegion getFloatingRegion) {
if (getFloatingRegion == null) {
return null;
}
if (getFloatingRegion instanceof FloatingRegionByRectangle) {
FloatingRegionByRectangle floatingRegionByRectangle = (FloatingRegionByRectangle) getFloatingRegion;
RectangleRegionDto rectangleRegionDto = RectangleRegionMapper
.toRectangleRegionDto(((FloatingRegionByRectangle) getFloatingRegion).getRegion());
RectangleFloatingRegionDto response = new RectangleFloatingRegionDto();
response.setRegion(rectangleRegionDto);
fillFloatingRegionDto(response, floatingRegionByRectangle);
return response;
} else if (getFloatingRegion instanceof FloatingRegionByElement) {
FloatingRegionByElement floatingRegionByElement = (FloatingRegionByElement) getFloatingRegion;
ElementRegionDto elementRegionDto = ElementRegionMapper.toElementRegionDto(floatingRegionByElement.getElement());
ElementFloatingRegionDto response = new ElementFloatingRegionDto();
response.setRegion(elementRegionDto);
fillFloatingRegionDto(response, floatingRegionByElement);
return response;
} else if (getFloatingRegion instanceof FloatingRegionBySelector) {
FloatingRegionBySelector floatingRegionBySelector = (FloatingRegionBySelector) getFloatingRegion;
SelectorRegionDto selectorRegionDto = SelectorRegionMapper
.toSelectorRegionDto(floatingRegionBySelector.getSelector());
SelectorFloatingRegionDto response = new SelectorFloatingRegionDto();
response.setRegion(selectorRegionDto);
fillFloatingRegionDto(response, floatingRegionBySelector);
return response;
} else if (getFloatingRegion instanceof FloatingRegionByTargetPathLocator) {
FloatingRegionByTargetPathLocator floatingRegionByTargetPathLocator = (FloatingRegionByTargetPathLocator) getFloatingRegion;
TargetPathLocatorDto targetPathLocatorDto = TargetPathLocatorMapper
.toTargetPathLocatorDto(floatingRegionByTargetPathLocator.getTargetPathLocator());
TargetPathLocatorFloatingRegionDto response = new TargetPathLocatorFloatingRegionDto();
response.setRegion(targetPathLocatorDto);
fillFloatingRegionDto(response, floatingRegionByTargetPathLocator);
return response;
}
return null;
}
private static void fillFloatingRegionDto(TFloatingRegion floatingRegionDto, IGetFloatingRegionOffsets getFloatingRegion) {
floatingRegionDto.setMaxUpOffset(getFloatingRegion.getMaxUpOffset());
floatingRegionDto.setMaxDownOffset(getFloatingRegion.getMaxDownOffset());
floatingRegionDto.setMaxLeftOffset(getFloatingRegion.getMaxLeftOffset());
floatingRegionDto.setMaxRightOffset(getFloatingRegion.getMaxRightOffset());
floatingRegionDto.setRegionId(getFloatingRegion.getRegionId());
}
public static List toTFloatingRegionDtoList(List getFloatingRegionList) {
if (getFloatingRegionList == null || getFloatingRegionList.isEmpty()) {
return null;
}
return getFloatingRegionList.stream().map(TFloatingRegionMapper::toTFloatingRegionDto).collect(Collectors.toList());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy