-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
APIM-7687 fix: enable trigger condition of policy in debug tab
- Loading branch information
1 parent
f9acaa3
commit db12cee
Showing
4 changed files
with
115 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...ervices-debug/src/main/java/io/gravitee/gateway/debug/policy/impl/DebugPolicyFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright © 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.gravitee.gateway.debug.policy.impl; | ||
|
||
import io.gravitee.gateway.policy.PolicyPluginFactory; | ||
import io.gravitee.gateway.reactive.core.condition.ExpressionLanguageConditionFilter; | ||
import io.gravitee.gateway.reactive.policy.HttpConditionalPolicy; | ||
import io.gravitee.gateway.reactive.policy.HttpPolicyFactory; | ||
import io.gravitee.node.api.configuration.Configuration; | ||
|
||
/** | ||
* {@code DebugPolicyFactory} extends {@link HttpPolicyFactory} to provide a customizable point | ||
* for adding debugging functionality for Debug Console. It inherits the behavior of | ||
* the default policy factory. | ||
*/ | ||
public class DebugPolicyFactory extends HttpPolicyFactory { | ||
|
||
public DebugPolicyFactory( | ||
Configuration configuration, | ||
PolicyPluginFactory policyPluginFactory, | ||
ExpressionLanguageConditionFilter<HttpConditionalPolicy> filter | ||
) { | ||
super(configuration, policyPluginFactory, filter); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...ces-debug/src/test/java/io/gravitee/gateway/debug/policy/impl/DebugPolicyFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright © 2015 The Gravitee team (http://gravitee.io) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.gravitee.gateway.debug.policy.impl; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import io.gravitee.gateway.policy.PolicyPluginFactory; | ||
import io.gravitee.gateway.reactive.core.condition.ExpressionLanguageConditionFilter; | ||
import io.gravitee.gateway.reactive.debug.policy.condition.DebugExpressionLanguageConditionFilter; | ||
import io.gravitee.gateway.reactive.policy.HttpConditionalPolicy; | ||
import io.gravitee.node.api.configuration.Configuration; | ||
import org.junit.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class DebugPolicyFactoryTest { | ||
|
||
@Mock | ||
private PolicyPluginFactory mockPolicyPluginFactory; | ||
|
||
@Mock | ||
private ExpressionLanguageConditionFilter<HttpConditionalPolicy> mockFilter; | ||
|
||
@Mock | ||
private Configuration configuration; | ||
|
||
@InjectMocks | ||
private DebugPolicyFactory debugPolicyFactory; | ||
|
||
@Test | ||
public void testConstructor_ShouldInstantiateCorrectly() { | ||
DebugPolicyFactory debugPolicyFactory = new DebugPolicyFactory( | ||
configuration, | ||
mockPolicyPluginFactory, | ||
new DebugExpressionLanguageConditionFilter() | ||
); | ||
// assert that the DebugPolicyFactory object is created successfully | ||
assertNotNull(debugPolicyFactory, "DebugPolicyFactory should be instantiated correctly"); | ||
} | ||
} |