use of com.linkedin.restli.common.ProtocolVersion in project rest.li by linkedin.
the class TestClientBuilders method checkBasicRequest.
private void checkBasicRequest(Request<?> request, URIDetails expectedURIDetails, ResourceMethod expectedMethod, CollectionRequest<?> expectedInput, BatchRequest<?> expectedBatchInput, Map<String, String> expectedHeaders, List<Object> expectedStreamingDataSources) {
final ProtocolVersion version = expectedURIDetails.getProtocolVersion();
checkBasicRequest(request, expectedURIDetails, expectedMethod, expectedInput, expectedHeaders, expectedStreamingDataSources);
if (request.getMethod() == ResourceMethod.BATCH_UPDATE || request.getMethod() == ResourceMethod.BATCH_PARTIAL_UPDATE) {
// check the conversion
checkInputForBatchUpdateAndPatch(request, expectedBatchInput, version);
}
}
use of com.linkedin.restli.common.ProtocolVersion in project rest.li by linkedin.
the class TestVersionNegotiation method getProtocolVersionClient.
@DataProvider(name = "data")
public Object[][] getProtocolVersionClient() {
ProtocolVersion lessThanDefaultVersion = new ProtocolVersion(0, 5, 0);
ProtocolVersion betweenDefaultAndLatestVersion = new ProtocolVersion(2, 5, 0);
ProtocolVersion greaterThanLatestVersion = new ProtocolVersion(3, 5, 0);
ProtocolVersion greaterThanNextVersion = new ProtocolVersion(3, 5, 0);
return new Object[][] { // baseline protocol "advertised" + graceful option => baseline protocol version
{ _BASELINE_VERSION, ProtocolVersionOption.USE_LATEST_IF_AVAILABLE, _BASELINE_VERSION }, // latest protocol "advertised" + force latest option => latest protocol version
{ _LATEST_VERSION, ProtocolVersionOption.FORCE_USE_LATEST, _LATEST_VERSION }, // baseline protocol "advertised" + force latest option => latest protocol version
{ _BASELINE_VERSION, ProtocolVersionOption.FORCE_USE_LATEST, _LATEST_VERSION }, // latest protocol "advertised" + graceful option => latest protocol version
{ _LATEST_VERSION, ProtocolVersionOption.USE_LATEST_IF_AVAILABLE, _LATEST_VERSION }, // use the version "advertised" by the server as it is less than the latest protocol version
{ betweenDefaultAndLatestVersion, ProtocolVersionOption.USE_LATEST_IF_AVAILABLE, betweenDefaultAndLatestVersion }, // servers should support it as well.
{ greaterThanNextVersion, ProtocolVersionOption.USE_LATEST_IF_AVAILABLE, _LATEST_VERSION }, // force latest option => latest protocol version
{ betweenDefaultAndLatestVersion, ProtocolVersionOption.FORCE_USE_LATEST, _LATEST_VERSION }, // force latest option => latest protocol version
{ lessThanDefaultVersion, ProtocolVersionOption.FORCE_USE_LATEST, _LATEST_VERSION }, // if servers "advertise" a version that is greater than the latest version we always use the latest version
{ greaterThanLatestVersion, ProtocolVersionOption.FORCE_USE_LATEST, _LATEST_VERSION }, // if servers "advertise" a version that is greater than the latest version we always use the latest version
{ greaterThanLatestVersion, ProtocolVersionOption.USE_LATEST_IF_AVAILABLE, _LATEST_VERSION }, // default version "advertised" + force next => next
{ _BASELINE_VERSION, ProtocolVersionOption.FORCE_USE_NEXT, _NEXT_VERSION }, // latest version "advertised" + force next => next
{ _LATEST_VERSION, ProtocolVersionOption.FORCE_USE_NEXT, _NEXT_VERSION }, // next "advertised" + force next => next
{ _NEXT_VERSION, ProtocolVersionOption.FORCE_USE_NEXT, _NEXT_VERSION }, // version between default and latest "advertised" + force next => next
{ betweenDefaultAndLatestVersion, ProtocolVersionOption.FORCE_USE_NEXT, _NEXT_VERSION }, // version greater than latest "advertised" + force next => next
{ greaterThanLatestVersion, ProtocolVersionOption.FORCE_USE_NEXT, _NEXT_VERSION }, // default version "advertised" + force next => next
{ _BASELINE_VERSION, ProtocolVersionOption.FORCE_USE_PREVIOUS, _PREV_VERSION }, // latest version "advertised" + force next => next
{ _LATEST_VERSION, ProtocolVersionOption.FORCE_USE_PREVIOUS, _PREV_VERSION }, // next "advertised" + force next => next
{ _NEXT_VERSION, ProtocolVersionOption.FORCE_USE_PREVIOUS, _PREV_VERSION }, // version between default and latest "advertised" + force next => next
{ betweenDefaultAndLatestVersion, ProtocolVersionOption.FORCE_USE_PREVIOUS, _PREV_VERSION }, // version greater than latest "advertised" + force next => next
{ greaterThanLatestVersion, ProtocolVersionOption.FORCE_USE_PREVIOUS, _PREV_VERSION } };
}
use of com.linkedin.restli.common.ProtocolVersion in project rest.li by linkedin.
the class TestVersionNegotiation method testAnnouncedVersionLessThanPrev.
@Test
public void testAnnouncedVersionLessThanPrev() {
try {
RestClient.getProtocolVersion(_BASELINE_VERSION, _PREV_VERSION, _LATEST_VERSION, _NEXT_VERSION, new ProtocolVersion(0, 0, 0), ProtocolVersionOption.USE_LATEST_IF_AVAILABLE, false);
Assert.fail("Expected a RuntimeException as the announced version is less than the earliest supported version!");
} catch (RuntimeException e) {
Assert.assertTrue(e.getMessage().contains("Announced version is less than the earliest supported version!"));
}
}
use of com.linkedin.restli.common.ProtocolVersion in project rest.li by linkedin.
the class TestVersionNegotiation method testAnnouncedVersionWithVersionPercentages.
@Test(dataProvider = "versionTestVariations")
public void testAnnouncedVersionWithVersionPercentages(ProtocolVersion versionInput, String versionPercentageInput, ProtocolVersion expectedAnnouncedVersion) {
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(RestConstants.RESTLI_PROTOCOL_VERSION_PROPERTY, versionInput);
properties.put(RestConstants.RESTLI_PROTOCOL_VERSION_PERCENTAGE_PROPERTY, versionPercentageInput);
ProtocolVersion announcedVersion = RestClient.getAnnouncedVersion(properties);
Assert.assertEquals(announcedVersion, expectedAnnouncedVersion);
}
use of com.linkedin.restli.common.ProtocolVersion in project rest.li by linkedin.
the class TestVersionNegotiation method testForceUseNextVersionOverride.
@Test(dataProvider = "testForceUseNextVersionOverrideData")
public void testForceUseNextVersionOverride(ProtocolVersionOption protocolVersionOption, ProtocolVersion expectedProtocolVersion, boolean forceUseOverrideSystemProperty) {
ProtocolVersion announcedVersion = new ProtocolVersion("2.0.0");
ProtocolVersion actualProtocolVersion = RestClient.getProtocolVersion(_BASELINE_VERSION, _PREV_VERSION, _LATEST_VERSION, _NEXT_VERSION, announcedVersion, protocolVersionOption, forceUseOverrideSystemProperty);
Assert.assertEquals(actualProtocolVersion, expectedProtocolVersion);
}
Aggregations