Uppercase ells ('L') in long literals

This commit removes all lowercase ells ('l') in long literals because
they are often hard to distinguish from the digit representing one
('1').

Closes elastic/elasticsearch#1414

Original commit: elastic/x-pack-elasticsearch@98b38705fb
This commit is contained in:
Jason Tedor 2016-01-30 20:12:15 -05:00
parent 9f886665fa
commit e13a5e695a
31 changed files with 128 additions and 128 deletions

View File

@ -43,7 +43,7 @@ public class LicenseVerificationTests extends ESTestCase {
final License tamperedLicense = License.builder()
.fromLicenseSpec(license, license.signature())
.expiryDate(license.expiryDate() + 10 * 24 * 60 * 60 * 1000l)
.expiryDate(license.expiryDate() + 10 * 24 * 60 * 60 * 1000L)
.validate()
.build();

View File

@ -96,8 +96,8 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
hit.score(1f);
hit.shard(new SearchShardTarget("a", new Index("a", "testUUID"), 0));
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1l, 1f), null, null, null, false, false);
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500l, new ShardSearchFailure[0]);
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1L, 1f), null, null, null, false, false);
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_watch_name", new Payload.XContent(response));
assertThat(condition.execute(ctx).met(), is(true));

View File

@ -61,7 +61,7 @@ public class ScriptConditionTests extends ESTestCase {
public void testExecute() throws Exception {
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("ctx.payload.hits.total > 1").build()), logger, scriptService);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
assertFalse(condition.execute(ctx).met());
}
@ -70,7 +70,7 @@ public class ScriptConditionTests extends ESTestCase {
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
Script script = Script.inline("ctx.payload.hits.total > threshold").lang(Script.DEFAULT_LANG).params(singletonMap("threshold", 1)).build();
ExecutableScriptCondition executable = new ExecutableScriptCondition(new ScriptCondition(script), logger, scriptService);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
assertFalse(executable.execute(ctx).met());
}
@ -85,7 +85,7 @@ public class ScriptConditionTests extends ESTestCase {
ScriptCondition condition = factory.parseCondition("_watch", parser);
ExecutableScriptCondition executable = factory.createExecutable(condition);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
assertFalse(executable.execute(ctx).met());
@ -163,7 +163,7 @@ public class ScriptConditionTests extends ESTestCase {
public void testScriptConditionThrowException() throws Exception {
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("assert false").build()), logger, scriptService);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
ScriptCondition.Result result = condition.execute(ctx);
assertThat(result, notNullValue());
@ -175,7 +175,7 @@ public class ScriptConditionTests extends ESTestCase {
public void testScriptConditionReturnObject() throws Exception {
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("return new Object()").build()), logger, scriptService);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
ScriptCondition.Result result = condition.execute(ctx);
assertThat(result, notNullValue());
@ -187,7 +187,7 @@ public class ScriptConditionTests extends ESTestCase {
public void testScriptConditionAccessCtx() throws Exception {
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("ctx.trigger.scheduled_time.getMillis() < new Date().time ").build()), logger, scriptService);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_name", new DateTime(DateTimeZone.UTC), new Payload.XContent(response));
Thread.sleep(10);
assertThat(condition.execute(ctx).met(), is(true));

View File

@ -119,13 +119,13 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
SearchResponse response = client().prepareSearch("output1").get();
assertNoFailures(response);
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
assertThat(response.getHits().getAt(0).sourceAsMap().get("key3").toString(), equalTo("20"));
response = client().prepareSearch("output2").get();
assertNoFailures(response);
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
assertThat(response.getHits().getAt(0).sourceAsMap().get("key3").toString(), equalTo("20"));
}
@ -168,12 +168,12 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
SearchResponse response = client().prepareSearch("output1").get();
assertNoFailures(response);
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
assertThat(response.getHits().getAt(0).sourceAsString(), containsString("mytestresult"));
response = client().prepareSearch("output2").get();
assertNoFailures(response);
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
assertThat(response.getHits().getAt(0).sourceAsString(), containsString("mytestresult"));
}
@ -212,13 +212,13 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
SearchResponse response = client().prepareSearch("output1").get();
assertNoFailures(response);
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
assertThat(response.getHits().getAt(0).sourceAsMap().get("key4").toString(), equalTo("30"));
response = client().prepareSearch("output2").get();
assertNoFailures(response);
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
assertThat(response.getHits().getAt(0).sourceAsMap().get("key4").toString(), equalTo("30"));
}

View File

@ -88,7 +88,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
.setSource(watchBuilder()
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
.input(searchInput(searchRequest))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L))
.addAction("_logger", loggingAction("\n\n************\n" +
"total hits: {{ctx.payload.hits.total}}\n" +
"************\n")
@ -114,7 +114,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
.setSource(watchBuilder()
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
.input(searchInput(searchRequest))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l)))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L)))
.get();
if (timeWarped()) {
@ -145,7 +145,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
.setSource(watchBuilder()
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
.input(searchInput(searchRequest))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l)))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L)))
.get();
assertThat(indexResponse.isCreated(), is(true));
@ -162,7 +162,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
assertThat(deleteWatchResponse.isFound(), is(true));
refresh();
assertHitCount(client().prepareSearch(WatchStore.INDEX).setSize(0).get(), 0l);
assertHitCount(client().prepareSearch(WatchStore.INDEX).setSize(0).get(), 0L);
// Deleting the same watch for the second time
deleteWatchResponse = watcherClient.prepareDeleteWatch("_name").get();
@ -214,7 +214,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
.addAction("_id", indexAction("idx", "action"));
watcherClient().preparePutWatch("_name")
.setSource(source.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l)))
.setSource(source.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L)))
.get();
if (timeWarped()) {
@ -225,7 +225,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
assertWatchWithMinimumPerformedActionsCount("_name", 0, false);
watcherClient().preparePutWatch("_name")
.setSource(source.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 0l)))
.setSource(source.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 0L)))
.get();
if (timeWarped()) {
@ -238,7 +238,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
watcherClient().preparePutWatch("_name")
.setSource(source
.trigger(schedule(Schedules.cron("0/1 * * * * ? 2020")))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 0l)))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 0L)))
.get();
if (timeWarped()) {
@ -340,14 +340,14 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
.setSource(watchBuilder()
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
.input(searchInput(searchRequest).extractKeys("hits.total"))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l)))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L)))
.get();
// in this watcher the condition will fail, because max_score isn't extracted, only total:
watcherClient.preparePutWatch("_name2")
.setSource(watchBuilder()
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
.input(searchInput(searchRequest).extractKeys("hits.total"))
.condition(compareCondition("ctx.payload.hits.max_score", CompareCondition.Op.GTE, 0l)))
.condition(compareCondition("ctx.payload.hits.max_score", CompareCondition.Op.GTE, 0L)))
.get();
if (timeWarped()) {
@ -454,7 +454,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase {
.setSource(watchBuilder()
.trigger(schedule(interval("5s")))
.input(searchInput(request))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GTE, 3l)))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GTE, 3L)))
.get();
logger.info("created watch [{}] at [{}]", watchName, SystemClock.INSTANCE.nowUTC());

View File

@ -94,7 +94,7 @@ public class EmailActionIntegrationTests extends AbstractWatcherIntegrationTestC
.setSource(watchBuilder()
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
.input(searchInput(searchRequest))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0l))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
.addAction("_email", emailAction(EmailTemplate.builder().from("_from").to("_to")
.subject("{{ctx.payload.hits.hits.0._source.field}}")).setAuthentication(USERNAME, PASSWORD.toCharArray())))
.get();

View File

@ -194,7 +194,7 @@ public class EmailAttachmentTests extends AbstractWatcherIntegrationTestCase {
WatchSourceBuilder watchSourceBuilder = watchBuilder()
.trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS)))
.input(searchInput(searchRequest))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0l))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
.addAction("_email", emailAction(emailBuilder).setAuthentication(USERNAME, PASSWORD.toCharArray())
.setAttachments(emailAttachments));
logger.info("TMP WATCHSOURCE {}", watchSourceBuilder.build().getBytes().toUtf8());

View File

@ -75,7 +75,7 @@ public class TimeThrottleIntegrationTests extends AbstractWatcherIntegrationTest
.setSource(watchBuilder()
.trigger(schedule(interval("5s")))
.input(searchInput(matchAllRequest().indices("events")))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0l))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
.transform(searchTransform(matchAllRequest().indices("events")))
.addAction("_id", indexAction("actions", "action"))
.defaultThrottlePeriod(TimeValue.timeValueSeconds(30)))
@ -149,7 +149,7 @@ public class TimeThrottleIntegrationTests extends AbstractWatcherIntegrationTest
.setSource(watchBuilder()
.trigger(schedule(interval("1s")))
.input(searchInput(matchAllRequest().indices("events")))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0l))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
.transform(searchTransform(matchAllRequest().indices("events")))
.addAction("_id", indexAction("actions", "action")))
.get();

View File

@ -643,7 +643,7 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
@Override
public boolean matches(long expirationDate, long now) {
long expiryDuration = expirationDate - now;
if (expiryDuration > 0l) {
if (expiryDuration > 0L) {
if (expiryDuration <= max.getMillis()) {
return expiryDuration >= min.getMillis();
}
@ -673,7 +673,7 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
@Override
public boolean matches(long expirationDate, long now) {
long postExpiryDuration = now - expirationDate;
if (postExpiryDuration > 0l) {
if (postExpiryDuration > 0L) {
if (postExpiryDuration <= max.getMillis()) {
return postExpiryDuration >= min.getMillis();
}
@ -684,12 +684,12 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
@Override
public TimeValue delay(long expiryDuration) {
final long delay;
if (expiryDuration >= 0l) {
if (expiryDuration >= 0L) {
delay = expiryDuration + min.getMillis();
} else {
delay = (-1l * expiryDuration) - min.getMillis();
delay = (-1L * expiryDuration) - min.getMillis();
}
if (delay > 0l) {
if (delay > 0L) {
return TimeValue.timeValueMillis(delay);
} else {
return null;

View File

@ -126,7 +126,7 @@ public abstract class AbstractLicensesConsumerPluginIntegrationTestCase extends
assertLicenseeState(consumerPlugin.id(), LicenseState.ENABLED);
logger.info(" --> sleep for rest of trailLicense duration");
Thread.sleep(trialLicenseDurationInSeconds * 1000l);
Thread.sleep(trialLicenseDurationInSeconds * 1000L);
logger.info(" --> check consumer is still enabled [signed license]");
// consumer plugin should notify onEnabled on all data nodes (signed license)

View File

@ -121,7 +121,7 @@ public class LicensesPluginIntegrationTests extends AbstractLicensesIntegrationT
assertLicenseeState(getCurrentFeatureName(), LicenseState.ENABLED);
logger.info(" --> sleep for rest of trailLicense duration");
Thread.sleep(trialLicenseDurationInSeconds * 1000l);
Thread.sleep(trialLicenseDurationInSeconds * 1000L);
logger.info(" --> check consumer is still enabled [signed license]");
// consumer plugin should notify onEnabled on all data nodes (signed license)

View File

@ -78,7 +78,7 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTestCase
// modify content of signed license
License tamperedLicense = License.builder()
.fromLicenseSpec(signedLicense, signedLicense.signature())
.expiryDate(signedLicense.expiryDate() + 10 * 24 * 60 * 60 * 1000l)
.expiryDate(signedLicense.expiryDate() + 10 * 24 * 60 * 60 * 1000L)
.validate()
.build();

View File

@ -117,7 +117,7 @@ public class TestUtils {
}
public static License generateSignedLicense(String type, long issueDate, TimeValue expiryDuration) throws Exception {
long issue = (issueDate != -1l) ? issueDate : System.currentTimeMillis();
long issue = (issueDate != -1L) ? issueDate : System.currentTimeMillis();
int version = randomIntBetween(License.VERSION_START, License.VERSION_CURRENT);
final String licenseType;
if (version < License.VERSION_NO_FEATURE_TYPE) {

View File

@ -79,7 +79,7 @@ public class LicensesManagerServiceTests extends ESSingleNodeTestCase {
// modify content of signed license
License tamperedLicense = License.builder()
.fromLicenseSpec(signedLicense, signedLicense.signature())
.expiryDate(signedLicense.expiryDate() + 10 * 24 * 60 * 60 * 1000l)
.expiryDate(signedLicense.expiryDate() + 10 * 24 * 60 * 60 * 1000L)
.validate()
.build();

View File

@ -306,10 +306,10 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
assertSearchHits(response, "1", "2");
Global globalAgg = response.getAggregations().get("global");
assertThat(globalAgg.getDocCount(), equalTo(2l));
assertThat(globalAgg.getDocCount(), equalTo(2L));
Terms termsAgg = globalAgg.getAggregations().get("field2");
assertThat(termsAgg.getBuckets().get(0).getKeyAsString(), equalTo("value2"));
assertThat(termsAgg.getBuckets().get(0).getDocCount(), equalTo(1l));
assertThat(termsAgg.getBuckets().get(0).getDocCount(), equalTo(1L));
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
.prepareSearch("test")
@ -319,7 +319,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
assertSearchHits(response, "1");
globalAgg = response.getAggregations().get("global");
assertThat(globalAgg.getDocCount(), equalTo(1l));
assertThat(globalAgg.getDocCount(), equalTo(1L));
termsAgg = globalAgg.getAggregations().get("field2");
assertThat(termsAgg.getBuckets().size(), equalTo(0));
}
@ -346,10 +346,10 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
assertSearchHits(response, "1");
Children children = response.getAggregations().get("children");
assertThat(children.getDocCount(), equalTo(1l));
assertThat(children.getDocCount(), equalTo(1L));
Terms termsAgg = children.getAggregations().get("field3");
assertThat(termsAgg.getBuckets().get(0).getKeyAsString(), equalTo("value3"));
assertThat(termsAgg.getBuckets().get(0).getDocCount(), equalTo(1l));
assertThat(termsAgg.getBuckets().get(0).getDocCount(), equalTo(1L));
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
.prepareSearch("test")
@ -361,7 +361,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
assertSearchHits(response, "1");
children = response.getAggregations().get("children");
assertThat(children.getDocCount(), equalTo(0l));
assertThat(children.getDocCount(), equalTo(0L));
termsAgg = children.getAggregations().get("field3");
assertThat(termsAgg.getBuckets().size(), equalTo(0));
}
@ -381,15 +381,15 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(hasChildQuery("child", matchAllQuery()))
.get();
assertHitCount(searchResponse, 1l);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertHitCount(searchResponse, 1L);
assertThat(searchResponse.getHits().totalHits(), equalTo(1L));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
searchResponse = client().prepareSearch("test")
.setQuery(hasParentQuery("parent", matchAllQuery()))
.addSort("_id", SortOrder.ASC)
.get();
assertHitCount(searchResponse, 2l);
assertHitCount(searchResponse, 2L);
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1"));
assertThat(searchResponse.getHits().getAt(1).id(), equalTo("c2"));
@ -398,25 +398,25 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
.prepareSearch("test")
.setQuery(hasChildQuery("child", matchAllQuery()))
.get();
assertHitCount(searchResponse, 0l);
assertHitCount(searchResponse, 0L);
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
.prepareSearch("test")
.setQuery(hasChildQuery("child", matchAllQuery()))
.get();
assertHitCount(searchResponse, 0l);
assertHitCount(searchResponse, 0L);
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user1", USERS_PASSWD)))
.prepareSearch("test")
.setQuery(hasParentQuery("parent", matchAllQuery()))
.get();
assertHitCount(searchResponse, 0l);
assertHitCount(searchResponse, 0L);
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
.prepareSearch("test")
.setQuery(hasParentQuery("parent", matchAllQuery()))
.get();
assertHitCount(searchResponse, 0l);
assertHitCount(searchResponse, 0L);
}
public void testPercolateApi() {
@ -434,7 +434,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
.setDocumentType("type")
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
.get();
assertThat(response.getCount(), equalTo(1l));
assertThat(response.getCount(), equalTo(1L));
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
// Percolator with a query on a document that the current user can see. Percolator will have one query to evaluate, so there is a match:
@ -444,7 +444,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
.setPercolateQuery(termQuery("field1", "value1"))
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
.get();
assertThat(response.getCount(), equalTo(1l));
assertThat(response.getCount(), equalTo(1L));
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
// Percolator with a query on a document that the current user can't see. Percolator will not have queries to evaluate, so there is no match:
@ -454,7 +454,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
.setPercolateQuery(termQuery("field1", "value1"))
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
.get();
assertThat(response.getCount(), equalTo(0l));
assertThat(response.getCount(), equalTo(0L));
assertAcked(client().admin().indices().prepareClose("test"));
assertAcked(client().admin().indices().prepareOpen("test"));
@ -466,7 +466,7 @@ public class DocumentLevelSecurityTests extends ShieldIntegTestCase {
.setDocumentType("type")
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
.get();
assertThat(response.getCount(), equalTo(1l));
assertThat(response.getCount(), equalTo(1L));
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
}

View File

@ -336,7 +336,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.setFields("field1", "field2")
.get();
assertThat(response.getAllFieldStats().size(), equalTo(1));
assertThat(response.getAllFieldStats().get("field1").getDocCount(), equalTo(1l));
assertThat(response.getAllFieldStats().get("field1").getDocCount(), equalTo(1L));
// user2 is granted access to field2 only:
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
@ -344,7 +344,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.setFields("field1", "field2")
.get();
assertThat(response.getAllFieldStats().size(), equalTo(1));
assertThat(response.getAllFieldStats().get("field2").getDocCount(), equalTo(1l));
assertThat(response.getAllFieldStats().get("field2").getDocCount(), equalTo(1L));
// user3 is granted access to field1 and field2:
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
@ -352,8 +352,8 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.setFields("field1", "field2")
.get();
assertThat(response.getAllFieldStats().size(), equalTo(2));
assertThat(response.getAllFieldStats().get("field1").getDocCount(), equalTo(1l));
assertThat(response.getAllFieldStats().get("field2").getDocCount(), equalTo(1l));
assertThat(response.getAllFieldStats().get("field1").getDocCount(), equalTo(1L));
assertThat(response.getAllFieldStats().get("field2").getDocCount(), equalTo(1L));
// user4 is granted access to no fields:
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD)))
@ -368,8 +368,8 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.setFields("field1", "field2")
.get();
assertThat(response.getAllFieldStats().size(), equalTo(2));
assertThat(response.getAllFieldStats().get("field1").getDocCount(), equalTo(1l));
assertThat(response.getAllFieldStats().get("field2").getDocCount(), equalTo(1l));
assertThat(response.getAllFieldStats().get("field1").getDocCount(), equalTo(1L));
assertThat(response.getAllFieldStats().get("field2").getDocCount(), equalTo(1L));
}
public void testQueryCache() throws Exception {
@ -541,7 +541,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.prepareSearch("test")
.addSort("field1", SortOrder.ASC)
.get();
assertThat((Long) response.getHits().getAt(0).sortValues()[0], equalTo(1l));
assertThat((Long) response.getHits().getAt(0).sortValues()[0], equalTo(1L));
// user2 is not granted to use field1, so the default missing sort value is included
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
@ -562,7 +562,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.prepareSearch("test")
.addSort("field2", SortOrder.ASC)
.get();
assertThat((Long) response.getHits().getAt(0).sortValues()[0], equalTo(2l));
assertThat((Long) response.getHits().getAt(0).sortValues()[0], equalTo(2L));
}
public void testAggs() throws Exception {
@ -578,7 +578,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.prepareSearch("test")
.addAggregation(AggregationBuilders.terms("_name").field("field1"))
.get();
assertThat(((Terms) response.getAggregations().get("_name")).getBucketByKey("value1").getDocCount(), equalTo(1l));
assertThat(((Terms) response.getAggregations().get("_name")).getBucketByKey("value1").getDocCount(), equalTo(1L));
// user2 is not authorized to use field1, so no buckets are include for a term agg on field1
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
@ -599,7 +599,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.prepareSearch("test")
.addAggregation(AggregationBuilders.terms("_name").field("field2"))
.get();
assertThat(((Terms) response.getAggregations().get("_name")).getBucketByKey("value2").getDocCount(), equalTo(1l));
assertThat(((Terms) response.getAggregations().get("_name")).getBucketByKey("value2").getDocCount(), equalTo(1L));
}
public void testTVApi() throws Exception {
@ -617,7 +617,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.get();
assertThat(response.isExists(), is(true));
assertThat(response.getFields().size(), equalTo(1));
assertThat(response.getFields().terms("field1").size(), equalTo(1l));
assertThat(response.getFields().terms("field1").size(), equalTo(1L));
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
.prepareTermVectors("test", "type1", "1")
@ -625,7 +625,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.get();
assertThat(response.isExists(), is(true));
assertThat(response.getFields().size(), equalTo(1));
assertThat(response.getFields().terms("field2").size(), equalTo(1l));
assertThat(response.getFields().terms("field2").size(), equalTo(1L));
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
.prepareTermVectors("test", "type1", "1")
@ -633,8 +633,8 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.get();
assertThat(response.isExists(), is(true));
assertThat(response.getFields().size(), equalTo(2));
assertThat(response.getFields().terms("field1").size(), equalTo(1l));
assertThat(response.getFields().terms("field2").size(), equalTo(1l));
assertThat(response.getFields().terms("field1").size(), equalTo(1L));
assertThat(response.getFields().terms("field2").size(), equalTo(1L));
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD)))
.prepareTermVectors("test", "type1", "1")
@ -660,7 +660,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
assertThat(response.getResponses().length, equalTo(1));
assertThat(response.getResponses()[0].getResponse().isExists(), is(true));
assertThat(response.getResponses()[0].getResponse().getFields().size(), equalTo(1));
assertThat(response.getResponses()[0].getResponse().getFields().terms("field1").size(), equalTo(1l));
assertThat(response.getResponses()[0].getResponse().getFields().terms("field1").size(), equalTo(1L));
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
.prepareMultiTermVectors()
@ -669,7 +669,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
assertThat(response.getResponses().length, equalTo(1));
assertThat(response.getResponses()[0].getResponse().isExists(), is(true));
assertThat(response.getResponses()[0].getResponse().getFields().size(), equalTo(1));
assertThat(response.getResponses()[0].getResponse().getFields().terms("field2").size(), equalTo(1l));
assertThat(response.getResponses()[0].getResponse().getFields().terms("field2").size(), equalTo(1L));
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user3", USERS_PASSWD)))
.prepareMultiTermVectors()
@ -678,8 +678,8 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
assertThat(response.getResponses().length, equalTo(1));
assertThat(response.getResponses()[0].getResponse().isExists(), is(true));
assertThat(response.getResponses()[0].getResponse().getFields().size(), equalTo(2));
assertThat(response.getResponses()[0].getResponse().getFields().terms("field1").size(), equalTo(1l));
assertThat(response.getResponses()[0].getResponse().getFields().terms("field2").size(), equalTo(1l));
assertThat(response.getResponses()[0].getResponse().getFields().terms("field1").size(), equalTo(1L));
assertThat(response.getResponses()[0].getResponse().getFields().terms("field2").size(), equalTo(1L));
response = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user4", USERS_PASSWD)))
.prepareMultiTermVectors()
@ -705,7 +705,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.setDocumentType("type")
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
.get();
assertThat(response.getCount(), equalTo(1l));
assertThat(response.getCount(), equalTo(1L));
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
// Percolator with a query on a field that the current user can't see. Percolator will not have queries to evaluate, so there is no match:
@ -715,7 +715,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.setPercolateQuery(termQuery("field1", "value1"))
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
.get();
assertThat(response.getCount(), equalTo(0l));
assertThat(response.getCount(), equalTo(0L));
assertAcked(client().admin().indices().prepareClose("test"));
assertAcked(client().admin().indices().prepareOpen("test"));
@ -727,7 +727,7 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.setDocumentType("type")
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}"))
.get();
assertThat(response.getCount(), equalTo(1l));
assertThat(response.getCount(), equalTo(1L));
assertThat(response.getMatches()[0].getId().string(), equalTo("1"));
}
@ -747,15 +747,15 @@ public class FieldLevelSecurityTests extends ShieldIntegTestCase {
.prepareSearch("test")
.setQuery(hasChildQuery("child", termQuery("field1", "yellow")))
.get();
assertHitCount(searchResponse, 1l);
assertThat(searchResponse.getHits().totalHits(), equalTo(1l));
assertHitCount(searchResponse, 1L);
assertThat(searchResponse.getHits().totalHits(), equalTo(1L));
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1"));
searchResponse = client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user2", USERS_PASSWD)))
.prepareSearch("test")
.setQuery(hasChildQuery("child", termQuery("field1", "yellow")))
.get();
assertHitCount(searchResponse, 0l);
assertHitCount(searchResponse, 0L);
}
public void testUpdateApiIsBlocked() throws Exception {

View File

@ -99,20 +99,20 @@ public class FieldDataCacheWithFieldSubsetReaderTests extends ESTestCase {
DirectoryReader ir = FieldSubsetReader.wrap(this.ir, Collections.<String>emptySet());
global = sortedSetDVOrdinalsIndexFieldData.loadGlobal(ir);
atomic = global.load(ir.leaves().get(0));
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0l));
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0L));
assertThat(indexFieldDataCache.topLevelBuilds, equalTo(1));
}
public void testSortedSetDVOrdinalsIndexFieldData_segment() throws Exception {
for (LeafReaderContext context : ir.leaves()) {
AtomicOrdinalsFieldData atomic = sortedSetDVOrdinalsIndexFieldData.load(context);
assertThat(atomic.getOrdinalsValues().getValueCount(), greaterThanOrEqualTo(1l));
assertThat(atomic.getOrdinalsValues().getValueCount(), greaterThanOrEqualTo(1L));
}
DirectoryReader ir = FieldSubsetReader.wrap(this.ir, Collections.<String>emptySet());
for (LeafReaderContext context : ir.leaves()) {
AtomicOrdinalsFieldData atomic = sortedSetDVOrdinalsIndexFieldData.load(context);
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0l));
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0L));
}
// dv based field data doesn't use index field data cache, so in the end noting should have been added
assertThat(indexFieldDataCache.leafLevelBuilds, equalTo(0));
@ -128,7 +128,7 @@ public class FieldDataCacheWithFieldSubsetReaderTests extends ESTestCase {
DirectoryReader ir = FieldSubsetReader.wrap(this.ir, Collections.<String>emptySet());
global = pagedBytesIndexFieldData.loadGlobal(ir);
atomic = global.load(ir.leaves().get(0));
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0l));
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0L));
assertThat(indexFieldDataCache.topLevelBuilds, equalTo(1));
}
@ -136,14 +136,14 @@ public class FieldDataCacheWithFieldSubsetReaderTests extends ESTestCase {
assertThat(indexFieldDataCache.leafLevelBuilds, equalTo(0));
for (LeafReaderContext context : ir.leaves()) {
AtomicOrdinalsFieldData atomic = pagedBytesIndexFieldData.load(context);
assertThat(atomic.getOrdinalsValues().getValueCount(), greaterThanOrEqualTo(1l));
assertThat(atomic.getOrdinalsValues().getValueCount(), greaterThanOrEqualTo(1L));
}
assertThat(indexFieldDataCache.leafLevelBuilds, equalTo(ir.leaves().size()));
DirectoryReader ir = FieldSubsetReader.wrap(this.ir, Collections.<String>emptySet());
for (LeafReaderContext context : ir.leaves()) {
AtomicOrdinalsFieldData atomic = pagedBytesIndexFieldData.load(context);
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0l));
assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0L));
}
assertThat(indexFieldDataCache.leafLevelBuilds, equalTo(ir.leaves().size()));
}

View File

@ -84,8 +84,8 @@ public class CompareConditionSearchTests extends AbstractWatcherIntegrationTestC
hit.score(1f);
hit.shard(new SearchShardTarget("a", new Index("a", "indexUUID"), 0));
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1l, 1f), null, null, null, false, false);
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500l, new ShardSearchFailure[0]);
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1L, 1f), null, null, null, false, false);
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_watch_name", new Payload.XContent(response));
assertThat(condition.execute(ctx).met(), is(true));

View File

@ -86,8 +86,8 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
hit.score(1f);
hit.shard(new SearchShardTarget("a", new Index("a", "testUUID"), 0));
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1l, 1f), null, null, null, false, false);
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500l, new ShardSearchFailure[0]);
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1L, 1f), null, null, null, false, false);
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_watch_name", new Payload.XContent(response));
assertThat(condition.execute(ctx).met(), is(true));

View File

@ -60,7 +60,7 @@ public class ScriptConditionTests extends ESTestCase {
public void testExecute() throws Exception {
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("ctx.payload.hits.total > 1").build()), logger, scriptService);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
assertFalse(condition.execute(ctx).met());
}
@ -69,7 +69,7 @@ public class ScriptConditionTests extends ESTestCase {
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
Script script = Script.inline("ctx.payload.hits.total > threshold").lang(Script.DEFAULT_LANG).params(singletonMap("threshold", 1)).build();
ExecutableScriptCondition executable = new ExecutableScriptCondition(new ScriptCondition(script), logger, scriptService);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
assertFalse(executable.execute(ctx).met());
}
@ -84,7 +84,7 @@ public class ScriptConditionTests extends ESTestCase {
ScriptCondition condition = factory.parseCondition("_watch", parser);
ExecutableScriptCondition executable = factory.createExecutable(condition);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
assertFalse(executable.execute(ctx).met());
@ -162,7 +162,7 @@ public class ScriptConditionTests extends ESTestCase {
public void testScriptConditionThrowException() throws Exception {
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("assert false").build()), logger, scriptService);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
ScriptCondition.Result result = condition.execute(ctx);
assertThat(result, notNullValue());
@ -174,7 +174,7 @@ public class ScriptConditionTests extends ESTestCase {
public void testScriptConditionReturnObject() throws Exception {
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("return new Object()").build()), logger, scriptService);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_name", new Payload.XContent(response));
ScriptCondition.Result result = condition.execute(ctx);
assertThat(result, notNullValue());
@ -186,7 +186,7 @@ public class ScriptConditionTests extends ESTestCase {
public void testScriptConditionAccessCtx() throws Exception {
ScriptServiceProxy scriptService = getScriptServiceProxy(tp);
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("ctx.trigger.scheduled_time.getMillis() < System.currentTimeMillis() ").build()), logger, scriptService);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500l, new ShardSearchFailure[0]);
SearchResponse response = new SearchResponse(InternalSearchResponse.empty(), "", 3, 3, 500L, new ShardSearchFailure[0]);
WatchExecutionContext ctx = mockExecutionContext("_name", new DateTime(DateTimeZone.UTC), new Payload.XContent(response));
Thread.sleep(10);
assertThat(condition.execute(ctx).met(), is(true));

View File

@ -56,7 +56,7 @@ public class TriggeredWatchStoreLifeCycleTests extends AbstractWatcherIntegratio
assertThat(loadedTriggeredWatches.contains(triggeredWatch), is(true));
triggeredWatchStore.delete(triggeredWatch.id());
GetResponse getResponse = client().prepareGet(TriggeredWatchStore.INDEX_NAME, TriggeredWatchStore.DOC_TYPE, triggeredWatch.id().value())
.setVersion(2l)
.setVersion(2L)
.get();
assertThat(getResponse.isExists(), equalTo(false));
}

View File

@ -269,7 +269,7 @@ public class TriggeredWatchStoreTests extends ESTestCase {
when(searchResponse1.getSuccessfulShards()).thenReturn(1);
when(searchResponse1.getTotalShards()).thenReturn(1);
InternalSearchHit hit = new InternalSearchHit(0, "_id", new Text("_type"), null);
hit.version(1l);
hit.version(1L);
hit.shard(new SearchShardTarget("_node_id", index, 0));
hit.sourceRef(new BytesArray("{}"));
InternalSearchHits hits = new InternalSearchHits(new InternalSearchHit[]{hit}, 1, 1.0f);
@ -279,7 +279,7 @@ public class TriggeredWatchStoreTests extends ESTestCase {
// First return a scroll response with a single hit and then with no hits
hit = new InternalSearchHit(0, "_id", new Text("_type"), null);
hit.version(1l);
hit.version(1L);
hit.shard(new SearchShardTarget("_node_id", index, 0));
hit.sourceRef(new BytesArray("{}"));
hits = new InternalSearchHits(new InternalSearchHit[]{hit}, 1, 1.0f);
@ -289,7 +289,7 @@ public class TriggeredWatchStoreTests extends ESTestCase {
TriggeredWatch triggeredWatch = mock(TriggeredWatch.class);
when(parser.parse(eq("_id"), eq(1l), any(BytesReference.class))).thenReturn(triggeredWatch);
when(parser.parse(eq("_id"), eq(1L), any(BytesReference.class))).thenReturn(triggeredWatch);
when(clientProxy.clearScroll(anyString())).thenReturn(new ClearScrollResponse(true, 1));

View File

@ -60,7 +60,7 @@ public class HttpInputIntegrationTests extends AbstractWatcherIntegrationTestCas
.path("/index/_search")
.body(jsonBuilder().startObject().field("size", 1).endObject())
.auth(shieldEnabled() ? new BasicAuth("test", "changeme".toCharArray()) : null)))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L))
.addAction("_id", loggingAction("watch [{{ctx.watch_id}}] matched")))
.get();
@ -79,7 +79,7 @@ public class HttpInputIntegrationTests extends AbstractWatcherIntegrationTestCas
.input(httpInput(HttpRequestTemplate.builder(address.getHostString(), address.getPort())
.path("/_cluster/stats")
.auth(shieldEnabled() ? new BasicAuth("test", "changeme".toCharArray()) : null)))
.condition(compareCondition("ctx.payload.nodes.count.total", CompareCondition.Op.GTE, 1l))
.condition(compareCondition("ctx.payload.nodes.count.total", CompareCondition.Op.GTE, 1L))
.addAction("_id", loggingAction("watch [{{ctx.watch_id}}] matched")))
.get();
@ -114,7 +114,7 @@ public class HttpInputIntegrationTests extends AbstractWatcherIntegrationTestCas
.setSource(watchBuilder()
.trigger(schedule(interval(10, IntervalSchedule.Interval.Unit.SECONDS)))
.input(httpInput(requestBuilder).extractKeys("hits.total"))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l)))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L)))
.get();
// in this watcher the condition will fail, because max_score isn't extracted, only total:
@ -122,7 +122,7 @@ public class HttpInputIntegrationTests extends AbstractWatcherIntegrationTestCas
.setSource(watchBuilder()
.trigger(schedule(interval(10, IntervalSchedule.Interval.Unit.SECONDS)))
.input(httpInput(requestBuilder).extractKeys("hits.total"))
.condition(compareCondition("ctx.payload.hits.max_score", CompareCondition.Op.GTE, 0l)))
.condition(compareCondition("ctx.payload.hits.max_score", CompareCondition.Op.GTE, 0L)))
.get();
if (timeWarped()) {

View File

@ -129,7 +129,7 @@ public class BasicShieldTests extends AbstractWatcherIntegrationTestCase {
.preparePutWatch("_id")
.setSource(watchBuilder().trigger(schedule(interval(5, IntervalSchedule.Interval.Unit.SECONDS))))
.get();
assertThat(putWatchResponse.getVersion(), equalTo(1l));
assertThat(putWatchResponse.getVersion(), equalTo(1L));
ExecuteWatchResponse executeWatchResponse = watcherClient().filterWithHeader(Collections.singletonMap("Authorization", token))
.prepareExecuteWatch("_id")
.setTriggerEvent(triggerEvent)
@ -137,7 +137,7 @@ public class BasicShieldTests extends AbstractWatcherIntegrationTestCase {
DeleteWatchResponse deleteWatchResponse = watcherClient().filterWithHeader(Collections.singletonMap("Authorization", token))
.prepareDeleteWatch("_id")
.get();
assertThat(deleteWatchResponse.getVersion(), equalTo(2l));
assertThat(deleteWatchResponse.getVersion(), equalTo(2L));
assertThat(deleteWatchResponse.isFound(), is(true));
// stats and get watch are also allowed by role monitor:

View File

@ -104,7 +104,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
// Only the valid watch should been loaded
assertThat(response.getWatchesCount(), equalTo(1l));
assertThat(response.getWatchesCount(), equalTo(1L));
assertThat(watcherClient().prepareGetWatch("_id0").get().getId(), Matchers.equalTo("_id0"));
}
@ -184,7 +184,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
assertThat(response.getWatchesCount(), equalTo(1l));
assertThat(response.getWatchesCount(), equalTo(1L));
}
public void testDeletedWhileQueued() throws Exception {
@ -221,7 +221,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
.setSource(watchBuilder()
.trigger(schedule(cron("0 0/5 * * * ? 2050")))
.input(searchInput(searchRequest))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L))
.buildAsBytes(XContentType.JSON)
)
.setConsistencyLevel(WriteConsistencyLevel.ALL)
@ -282,7 +282,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
// that numRecords watch records have been processed as part of starting up.
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
assertThat(response.getThreadPoolQueueSize(), equalTo(0l));
assertThat(response.getThreadPoolQueueSize(), equalTo(0L));
// but even then since the execution of the watch record is async it may take a little bit before
// the actual documents are in the output index
@ -333,7 +333,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
// that numRecords watch records have been processed as part of starting up.
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
assertThat(response.getThreadPoolQueueSize(), equalTo(0l));
assertThat(response.getThreadPoolQueueSize(), equalTo(0L));
// but even then since the execution of the watch record is async it may take a little bit before
// the actual documents are in the output index
@ -390,7 +390,7 @@ public class BootStrapTests extends AbstractWatcherIntegrationTestCase {
// that numRecords watch records have been processed as part of starting up.
WatcherStatsResponse response = watcherClient().prepareWatcherStats().get();
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
assertThat(response.getThreadPoolQueueSize(), equalTo(0l));
assertThat(response.getThreadPoolQueueSize(), equalTo(0L));
// but even then since the execution of the watch record is async it may take a little bit before
// the actual documents are in the output index

View File

@ -94,7 +94,7 @@ public class NoMasterNodeTests extends AbstractWatcherIntegrationTestCase {
WatchSourceBuilder watchSource = watchBuilder()
.trigger(schedule(cron("0/5 * * * * ? *")))
.input(searchInput(searchRequest))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l));
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L));
// we first need to make sure the license is enabled, otherwise all APIs will be blocked
ensureLicenseEnabled();
@ -203,7 +203,7 @@ public class NoMasterNodeTests extends AbstractWatcherIntegrationTestCase {
WatchSourceBuilder watchSource = watchBuilder()
.trigger(schedule(cron("0/5 * * * * ? *")))
.input(searchInput(searchRequest))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l));
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L));
watcherClient().preparePutWatch(watchName).setSource(watchSource).get();
}
ensureGreen();
@ -254,7 +254,7 @@ public class NoMasterNodeTests extends AbstractWatcherIntegrationTestCase {
assertThat(watcherService.state(), is(WatcherState.STOPPED));
}
for (ExecutionService executionService : internalCluster().getInstances(ExecutionService.class)) {
assertThat(executionService.executionThreadPoolQueueSize(), equalTo(0l));
assertThat(executionService.executionThreadPoolQueueSize(), equalTo(0L));
}
}

View File

@ -58,7 +58,7 @@ public class WatchMetadataTests extends AbstractWatcherIntegrationTestCase {
.setSource(watchBuilder()
.trigger(schedule(cron("0/5 * * * * ? *")))
.input(searchInput(WatcherTestUtils.newInputSearchRequest("my-index").source(searchSource().query(matchAllQuery()))))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L))
.metadata(metadata))
.get();

View File

@ -108,13 +108,13 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
SearchResponse response = client().prepareSearch("output1").get();
assertNoFailures(response);
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
assertThat(response.getHits().getAt(0).sourceAsMap().get("key3").toString(), equalTo("20"));
response = client().prepareSearch("output2").get();
assertNoFailures(response);
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
assertThat(response.getHits().getAt(0).sourceAsMap().get("key3").toString(), equalTo("20"));
}
@ -157,12 +157,12 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
SearchResponse response = client().prepareSearch("output1").get();
assertNoFailures(response);
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
assertThat(response.getHits().getAt(0).sourceAsString(), containsString("mytestresult"));
response = client().prepareSearch("output2").get();
assertNoFailures(response);
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
assertThat(response.getHits().getAt(0).sourceAsString(), containsString("mytestresult"));
}
@ -201,13 +201,13 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
SearchResponse response = client().prepareSearch("output1").get();
assertNoFailures(response);
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
assertThat(response.getHits().getAt(0).sourceAsMap().get("key4").toString(), equalTo("30"));
response = client().prepareSearch("output2").get();
assertNoFailures(response);
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1l));
assertThat(response.getHits().getTotalHits(), greaterThanOrEqualTo(1L));
assertThat(response.getHits().getAt(0).sourceAsMap().size(), equalTo(1));
assertThat(response.getHits().getAt(0).sourceAsMap().get("key4").toString(), equalTo("30"));
}

View File

@ -73,7 +73,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
.setSource(watchBuilder()
.trigger(schedule(cron("0/5 * * * * ? *")))
.input(searchInput(matchAllRequest().indices("events")))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0l))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
.transform(searchTransform(matchAllRequest().indices("events")))
.addAction("_a1", indexAction("actions", "action1"))
.addAction("_a2", indexAction("actions", "action2"))
@ -145,7 +145,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
.setSource(watchBuilder()
.trigger(schedule(cron("0/5 * * * * ? *")))
.input(searchInput(matchAllRequest().indices("events")))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0l))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
.transform(searchTransform(matchAllRequest().indices("events")))
.addAction("_a1", indexAction("actions", "action1"))
.addAction("_a2", indexAction("actions", "action2"))
@ -224,7 +224,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
.setSource(watchBuilder()
.trigger(schedule(cron("0/5 * * * * ? *")))
.input(searchInput(matchAllRequest().indices("events")))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0l))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
.transform(searchTransform(matchAllRequest().indices("events")))
.addAction("_id", indexAction("actions", "action")))
.get();

View File

@ -72,7 +72,7 @@ public class SlowWatchStatsTests extends AbstractWatcherIntegrationTestCase {
public void run() {
WatcherStatsResponse response = watcherClient().prepareWatcherStats().setIncludeCurrentWatches(true).get();
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
assertThat(response.getWatchesCount(), equalTo(1l));
assertThat(response.getWatchesCount(), equalTo(1L));
assertThat(response.getQueuedWatches(), nullValue());
assertThat(response.getSnapshots(), notNullValue());
assertThat(response.getSnapshots().size(), equalTo(1));
@ -98,7 +98,7 @@ public class SlowWatchStatsTests extends AbstractWatcherIntegrationTestCase {
public void run() {
WatcherStatsResponse response = watcherClient().prepareWatcherStats().setIncludeQueuedWatches(true).get();
assertThat(response.getWatcherState(), equalTo(WatcherState.STARTED));
assertThat(response.getWatchesCount(), equalTo(5l));
assertThat(response.getWatchesCount(), equalTo(5L));
assertThat(response.getSnapshots(), nullValue());
assertThat(response.getQueuedWatches(), notNullValue());
assertThat(response.getQueuedWatches().size(), greaterThanOrEqualTo(5));

View File

@ -63,7 +63,7 @@ public class WatcherStatsTests extends AbstractWatcherIntegrationTestCase {
.setSource(watchBuilder()
.trigger(schedule(cron("* * * * * ? *")))
.input(searchInput(searchRequest))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1l))
.condition(compareCondition("ctx.payload.hits.total", CompareCondition.Op.EQ, 1L))
)
.get();