11
11
import org .opensearch .common .io .stream .BytesStreamOutput ;
12
12
import org .opensearch .core .common .io .stream .StreamInput ;
13
13
import org .opensearch .rule .GetRuleRequest ;
14
- import org .opensearch .rule .InMemoryRuleProcessingServiceTests ;
15
14
import org .opensearch .rule .autotagging .Attribute ;
16
15
import org .opensearch .rule .autotagging .Rule ;
16
+ import org .opensearch .rule .utils .RuleTestUtils ;
17
17
import org .opensearch .test .OpenSearchTestCase ;
18
18
19
19
import java .io .IOException ;
20
20
import java .util .HashMap ;
21
21
import java .util .Map ;
22
22
import java .util .Set ;
23
23
24
- import static org .opensearch .rule .InMemoryRuleProcessingServiceTests .WLMFeatureType ;
25
-
26
24
public class GetRuleRequestTests extends OpenSearchTestCase {
27
25
/**
28
26
* Test case to verify the serialization and deserialization of GetRuleRequest
29
27
*/
30
28
public void testSerialization () throws IOException {
31
- GetRuleRequest request = new GetRuleRequest (_ID_ONE , ATTRIBUTE_MAP , null , WLMFeatureType . WLM );
29
+ GetRuleRequest request = new GetRuleRequest (_ID_ONE , ATTRIBUTE_MAP , null , RuleTestUtils . MockRuleFeatureType . INSTANCE );
32
30
assertEquals (_ID_ONE , request .getId ());
33
31
BytesStreamOutput out = new BytesStreamOutput ();
34
32
request .writeTo (out );
@@ -42,7 +40,12 @@ public void testSerialization() throws IOException {
42
40
* Test case to verify the serialization and deserialization of GetRuleRequest when name is null
43
41
*/
44
42
public void testSerializationWithNull () throws IOException {
45
- GetRuleRequest request = new GetRuleRequest ((String ) null , new HashMap <>(), SEARCH_AFTER , WLMFeatureType .WLM );
43
+ GetRuleRequest request = new GetRuleRequest (
44
+ (String ) null ,
45
+ new HashMap <>(),
46
+ SEARCH_AFTER ,
47
+ RuleTestUtils .MockRuleFeatureType .INSTANCE
48
+ );
46
49
assertNull (request .getId ());
47
50
BytesStreamOutput out = new BytesStreamOutput ();
48
51
request .writeTo (out );
@@ -64,23 +67,23 @@ public void testSerializationWithNull() throws IOException {
64
67
public static final String TIMESTAMP_ONE = "2024-01-26T08:58:57.558Z" ;
65
68
public static final String TIMESTAMP_TWO = "2023-01-26T08:58:57.558Z" ;
66
69
public static final Map <Attribute , Set <String >> ATTRIBUTE_MAP = Map .of (
67
- InMemoryRuleProcessingServiceTests . TestAttribute . TEST_ATTRIBUTE ,
70
+ RuleTestUtils . MockRuleAttributes . MOCK_RULE_ATTRIBUTE_ONE ,
68
71
Set .of (ATTRIBUTE_VALUE_ONE )
69
72
);
70
73
71
74
public static final Rule ruleOne = Rule .builder ()
72
75
.description (DESCRIPTION_ONE )
73
- .featureType (WLMFeatureType . WLM )
76
+ .featureType (RuleTestUtils . MockRuleFeatureType . INSTANCE )
74
77
.featureValue (FEATURE_VALUE_ONE )
75
78
.attributeMap (ATTRIBUTE_MAP )
76
79
.updatedAt (TIMESTAMP_ONE )
77
80
.build ();
78
81
79
82
public static final Rule ruleTwo = Rule .builder ()
80
83
.description (DESCRIPTION_TWO )
81
- .featureType (WLMFeatureType . WLM )
84
+ .featureType (RuleTestUtils . MockRuleFeatureType . INSTANCE )
82
85
.featureValue (FEATURE_VALUE_TWO )
83
- .attributeMap (Map .of (InMemoryRuleProcessingServiceTests . TestAttribute . TEST_ATTRIBUTE , Set .of (ATTRIBUTE_VALUE_TWO )))
86
+ .attributeMap (Map .of (RuleTestUtils . MockRuleAttributes . MOCK_RULE_ATTRIBUTE_TWO , Set .of (ATTRIBUTE_VALUE_TWO )))
84
87
.updatedAt (TIMESTAMP_TWO )
85
88
.build ();
86
89
0 commit comments