This commit is contained in:
Clebert Suconic 2021-08-05 09:22:16 -04:00
commit da04ee2d31
8 changed files with 29 additions and 3 deletions

View File

@ -63,7 +63,7 @@ public class StatQueue extends AbstractAction {
} }
public enum OPERATION { public enum OPERATION {
CONTAINS, EQUALS, GREATER_THAN, LESS_THAN CONTAINS, NOT_CONTAINS, EQUALS, GREATER_THAN, LESS_THAN
} }
public static final int DEFAULT_MAX_ROWS = 50; public static final int DEFAULT_MAX_ROWS = 50;
@ -74,7 +74,7 @@ public class StatQueue extends AbstractAction {
@Option(name = "--field", description = "field to use in filter. Possible values NAME, ADDRESS, MESSAGE_COUNT, MESSAGES_ADDED, DELIVERING_COUNT, MESSAGES_ACKED, SCHEDULED_COUNT, ROUTING_TYPE.") @Option(name = "--field", description = "field to use in filter. Possible values NAME, ADDRESS, MESSAGE_COUNT, MESSAGES_ADDED, DELIVERING_COUNT, MESSAGES_ACKED, SCHEDULED_COUNT, ROUTING_TYPE.")
private String fieldName; private String fieldName;
@Option(name = "--operation", description = "operation to use in filter. Possible values CONTAINS, EQUALS, GREATER_THAN, LESS_THAN.") @Option(name = "--operation", description = "operation to use in filter. Possible values CONTAINS, NOT_CONTAINS, EQUALS, GREATER_THAN, LESS_THAN.")
private String operationName; private String operationName;
@Option(name = "--value", description = "value to use in the filter.") @Option(name = "--value", description = "value to use in the filter.")

View File

@ -1384,6 +1384,19 @@ public class ArtemisTest extends CliTestBase {
// Header line + 3 queues // Header line + 3 queues
Assert.assertEquals("rows returned filtering by NAME ", 4, lines.size()); Assert.assertEquals("rows returned filtering by NAME ", 4, lines.size());
//check all queues NOT containing "management" are displayed using Filter field NAME
context = new TestActionContext();
statQueue = new StatQueue();
statQueue.setUser("admin");
statQueue.setPassword("admin");
statQueue.setFieldName("NAME");
statQueue.setOperationName("NOT_CONTAINS");
statQueue.setValue("management");
statQueue.execute(context);
lines = getOutputLines(context, false);
// Header line + 6 queues (Test1/11/12/20+DLQ+ExpiryQueue, but not activemq.management.d6dbba78-d76f-43d6-a2c9-fc0575ed6f5d)
Assert.assertEquals("rows returned filtering by NAME operation NOT_CONTAINS", 7, lines.size());
//check only queue named "Test1" is displayed using Filter field NAME and operation EQUALS //check only queue named "Test1" is displayed using Filter field NAME and operation EQUALS
context = new TestActionContext(); context = new TestActionContext();
statQueue = new StatQueue(); statQueue = new StatQueue();

View File

@ -106,6 +106,7 @@ var Artemis;
operationOptions: [ operationOptions: [
{id: 'EQUALS', name: 'Equals'}, {id: 'EQUALS', name: 'Equals'},
{id: 'CONTAINS', name: 'Contains'}, {id: 'CONTAINS', name: 'Contains'},
{id: 'NOT_CONTAINS', name: 'Does Not Contain'},
{id: 'GREATER_THAN', name: 'Greater Than'}, {id: 'GREATER_THAN', name: 'Greater Than'},
{id: 'LESS_THAN', name: 'Less Than'} {id: 'LESS_THAN', name: 'Less Than'}
], ],

View File

@ -130,6 +130,7 @@ var Artemis;
operationOptions: [ operationOptions: [
{id: 'EQUALS', name: 'Equals'}, {id: 'EQUALS', name: 'Equals'},
{id: 'CONTAINS', name: 'Contains'}, {id: 'CONTAINS', name: 'Contains'},
{id: 'NOT_CONTAINS', name: 'Does Not Contain'},
{id: 'GREATER_THAN', name: 'Greater Than'}, {id: 'GREATER_THAN', name: 'Greater Than'},
{id: 'LESS_THAN', name: 'Less Than'} {id: 'LESS_THAN', name: 'Less Than'}
], ],

View File

@ -130,6 +130,7 @@ var Artemis;
operationOptions: [ operationOptions: [
{id: 'EQUALS', name: 'Equals'}, {id: 'EQUALS', name: 'Equals'},
{id: 'CONTAINS', name: 'Contains'}, {id: 'CONTAINS', name: 'Contains'},
{id: 'NOT_CONTAINS', name: 'Does Not Contain'},
{id: 'GREATER_THAN', name: 'Greater Than'}, {id: 'GREATER_THAN', name: 'Greater Than'},
{id: 'LESS_THAN', name: 'Less Than'} {id: 'LESS_THAN', name: 'Less Than'}
], ],

View File

@ -144,6 +144,7 @@ var Artemis;
operationOptions: [ operationOptions: [
{id: 'EQUALS', name: 'Equals'}, {id: 'EQUALS', name: 'Equals'},
{id: 'CONTAINS', name: 'Contains'}, {id: 'CONTAINS', name: 'Contains'},
{id: 'NOT_CONTAINS', name: 'Does Not Contain'},
{id: 'GREATER_THAN', name: 'Greater Than'}, {id: 'GREATER_THAN', name: 'Greater Than'},
{id: 'LESS_THAN', name: 'Less Than'} {id: 'LESS_THAN', name: 'Less Than'}
], ],

View File

@ -125,6 +125,7 @@ var Artemis;
operationOptions: [ operationOptions: [
{id: 'EQUALS', name: 'Equals'}, {id: 'EQUALS', name: 'Equals'},
{id: 'CONTAINS', name: 'Contains'}, {id: 'CONTAINS', name: 'Contains'},
{id: 'NOT_CONTAINS', name: 'Does Not Contain'},
{id: 'GREATER_THAN', name: 'Greater Than'}, {id: 'GREATER_THAN', name: 'Greater Than'},
{id: 'LESS_THAN', name: 'Less Than'} {id: 'LESS_THAN', name: 'Less Than'}
], ],

View File

@ -23,7 +23,7 @@ import java.util.function.Predicate;
public class ActiveMQFilterPredicate<T> implements Predicate<T> { public class ActiveMQFilterPredicate<T> implements Predicate<T> {
enum Operation { enum Operation {
CONTAINS, EQUALS, GREATER_THAN, LESS_THAN; CONTAINS, NOT_CONTAINS, EQUALS, GREATER_THAN, LESS_THAN;
} }
protected String field; protected String field;
@ -77,6 +77,8 @@ public class ActiveMQFilterPredicate<T> implements Predicate<T> {
return equals(field, value); return equals(field, value);
case CONTAINS: case CONTAINS:
return contains(field, value); return contains(field, value);
case NOT_CONTAINS:
return !contains(field, value);
case GREATER_THAN: case GREATER_THAN:
return false; return false;
case LESS_THAN: case LESS_THAN:
@ -110,6 +112,8 @@ public class ActiveMQFilterPredicate<T> implements Predicate<T> {
return field == longValue; return field == longValue;
case CONTAINS: case CONTAINS:
return false; return false;
case NOT_CONTAINS:
return false;
case LESS_THAN: case LESS_THAN:
return field < longValue; return field < longValue;
case GREATER_THAN: case GREATER_THAN:
@ -135,6 +139,8 @@ public class ActiveMQFilterPredicate<T> implements Predicate<T> {
return field == intValue; return field == intValue;
case CONTAINS: case CONTAINS:
return false; return false;
case NOT_CONTAINS:
return false;
case LESS_THAN: case LESS_THAN:
return field < intValue; return field < intValue;
case GREATER_THAN: case GREATER_THAN:
@ -160,6 +166,8 @@ public class ActiveMQFilterPredicate<T> implements Predicate<T> {
return field == floatValue; return field == floatValue;
case CONTAINS: case CONTAINS:
return false; return false;
case NOT_CONTAINS:
return false;
case LESS_THAN: case LESS_THAN:
return field < floatValue; return field < floatValue;
case GREATER_THAN: case GREATER_THAN: