diff options
6 files changed, 16 insertions, 17 deletions
@@ -136,7 +136,7 @@ <dependency> <groupId>org.onap.holmes.common</groupId> <artifactId>holmes-actions</artifactId> - <version>1.4.3</version> + <version>1.4.4</version> <exclusions> <exclusion> <groupId>io.swagger</groupId> diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTask.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTask.java index d24d567..650ebbb 100644 --- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTask.java +++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTask.java @@ -186,6 +186,7 @@ public class ConfigFileScanningTask implements Runnable { private boolean deployRule(String clName, String contents) { RuleCreateRequest ruleCreateRequest = getRuleCreateRequest(clName, contents); if (JerseyClient.newInstance().header("Accept", MediaType.APPLICATION_JSON) + .header("username", DEFAULT_CREATOR) .put(url, Entity.json(ruleCreateRequest)) == null) { LOGGER.error("Failed to deploy rule: {}.", clName); return false; @@ -200,7 +201,6 @@ public class ConfigFileScanningTask implements Runnable { ruleCreateRequest.setContent(contents); ruleCreateRequest.setDescription(""); ruleCreateRequest.setEnabled(1); - ruleCreateRequest.setCreator(DEFAULT_CREATOR); return ruleCreateRequest; } diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/resources/RuleMgtResources.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/resources/RuleMgtResources.java index 133e859..2c9a462 100644 --- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/resources/RuleMgtResources.java +++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/resources/RuleMgtResources.java @@ -62,10 +62,9 @@ public class RuleMgtResources { try {
ruleChangeResponse = ruleMgtWrapper
.addCorrelationRule(UserUtil.getUserName(request), ruleCreateRequest);
- log.info("create rule:" + ruleCreateRequest.getRuleName() + " success.");
return ruleChangeResponse;
} catch (CorrelationException e) {
- log.error("create rule:" + ruleCreateRequest.getRuleName() + " failed", e);
+ log.error(String.format("failed to create the rule: %s", ruleCreateRequest.getRuleName()), e);
throw ExceptionUtil.buildExceptionResponse(e.getMessage());
}
}
@@ -85,7 +84,7 @@ public class RuleMgtResources { log.info("update rule:" + ruleUpdateRequest.getRuleId() + " successful");
return ruleChangeResponse;
} catch (CorrelationException e) {
- log.error("update rule:" + ruleUpdateRequest.getContent() + " failed", e);
+ log.error(String.format("failed to update the rule: %s", ruleUpdateRequest.getRuleId()), e);
throw ExceptionUtil.buildExceptionResponse(e.getMessage());
}
}
@@ -95,10 +94,9 @@ public class RuleMgtResources { public ResponseEntity deleteCorrelationRule(@PathVariable("ruleid") String ruleId) {
try {
ruleMgtWrapper.deleteCorrelationRule(new RuleDeleteRequest(ruleId));
- log.info("delete rule:" + ruleId + " successful");
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
} catch (CorrelationException e) {
- log.error("delete rule:" + ruleId + " failed", e);
+ log.error(String.format("failed to delete the rule: %s", ruleId), e);
throw ExceptionUtil.buildExceptionResponse(e.getMessage());
}
}
@@ -118,10 +116,9 @@ public class RuleMgtResources { try {
ruleQueryListResponse = ruleMgtWrapper
.getCorrelationRuleByCondition(ruleQueryCondition);
- log.info("query rule successful by condition:" + ruleQueryCondition);
return ruleQueryListResponse;
} catch (CorrelationException e) {
- log.error("query rule failed,cause query condition conversion failure", e);
+ log.error(String.format("failed to query the rule: %s", ruleQueryCondition.getName()), e);
throw ExceptionUtil.buildExceptionResponse(e.getMessage());
}
}
diff --git a/rulemgt/src/main/resources/logback-spring.xml b/rulemgt/src/main/resources/logback-spring.xml index 197057e..eda9c6b 100644 --- a/rulemgt/src/main/resources/logback-spring.xml +++ b/rulemgt/src/main/resources/logback-spring.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <configuration debug="false"> <property name="LOG_HOME" value="/var/log/ONAP/holmes"/> - <property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%c][%t] - %msg%n" /> + <property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%c][%t][%X{RequestID}][%X{InvocationID}] - %m%n" /> <appender name="Console" class="ch.qos.logback.core.ConsoleAppender"> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> diff --git a/rulemgt/src/test/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTaskTest.java b/rulemgt/src/test/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTaskTest.java index a4ab15b..cc29103 100644 --- a/rulemgt/src/test/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTaskTest.java +++ b/rulemgt/src/test/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTaskTest.java @@ -28,6 +28,7 @@ import org.onap.holmes.rulemgt.bean.response.RuleQueryListResponse; import org.onap.holmes.rulemgt.bean.response.RuleResult4API; import org.powermock.api.easymock.PowerMock; import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.reflect.Whitebox; @@ -37,6 +38,7 @@ import static org.junit.Assert.assertThat; @RunWith(PowerMockRunner.class) @PrepareForTest({JerseyClient.class}) +@SuppressStaticInitializationFor({"org.onap.holmes.common.utils.JerseyClient"}) public class ConfigFileScanningTaskTest { @Rule @@ -81,7 +83,7 @@ public class ConfigFileScanningTaskTest { EasyMock.expect(jcMock.get(EasyMock.anyString(), EasyMock.anyObject())).andReturn(rqlr); // mock for deployRule - EasyMock.expect(jcMock.header(EasyMock.anyString(), EasyMock.anyObject())).andReturn(jcMock); + EasyMock.expect(jcMock.header(EasyMock.anyString(), EasyMock.anyObject())).andReturn(jcMock).times(2); EasyMock.expect(jcMock.put(EasyMock.anyString(), EasyMock.anyObject())).andReturn(""); PowerMock.replayAll(); @@ -169,7 +171,7 @@ public class ConfigFileScanningTaskTest { EasyMock.expect(jcMock.delete(EasyMock.anyString())).andReturn(""); // mock for deployRule - EasyMock.expect(jcMock.header(EasyMock.anyString(), EasyMock.anyObject())).andReturn(jcMock); + EasyMock.expect(jcMock.header(EasyMock.anyString(), EasyMock.anyObject())).andReturn(jcMock).times(2); EasyMock.expect(jcMock.put(EasyMock.anyString(), EasyMock.anyObject())).andReturn(""); PowerMock.replayAll(); diff --git a/rulemgt/src/test/java/org/onap/holmes/rulemgt/resources/RuleMgtResourcesTest.java b/rulemgt/src/test/java/org/onap/holmes/rulemgt/resources/RuleMgtResourcesTest.java index a515196..7cc0def 100644 --- a/rulemgt/src/test/java/org/onap/holmes/rulemgt/resources/RuleMgtResourcesTest.java +++ b/rulemgt/src/test/java/org/onap/holmes/rulemgt/resources/RuleMgtResourcesTest.java @@ -51,7 +51,7 @@ public class RuleMgtResourcesTest { private RuleMgtResources ruleMgtResources = new RuleMgtResources();
@Before
- public void setUp() throws Exception {
+ public void setUp() {
Whitebox.setInternalState(ruleMgtResources, "ruleMgtWrapper", ruleMgtWrapper);
PowerMock.resetAll();
}
@@ -64,7 +64,7 @@ public class RuleMgtResourcesTest { final RuleCreateRequest ruleCreateRequest = new RuleCreateRequest();
EasyMock.expect(ruleMgtWrapper.addCorrelationRule("admin", ruleCreateRequest))
.andThrow(new CorrelationException(EasyMock.anyObject(String.class)));
- EasyMock.expect(request.getHeader("username")).andReturn("admin");
+ EasyMock.expect(request.getHeader("username")).andReturn("admin").times(2);
PowerMock.replayAll();
ruleMgtResources.addCorrelationRule(request, ruleCreateRequest);
PowerMock.verifyAll();
@@ -76,7 +76,7 @@ public class RuleMgtResourcesTest { final RuleCreateRequest ruleCreateRequest = new RuleCreateRequest();
EasyMock.expect(ruleMgtWrapper.addCorrelationRule("admin",
ruleCreateRequest)).andReturn(new RuleAddAndUpdateResponse());
- EasyMock.expect(request.getHeader("username")).andReturn("admin");
+ EasyMock.expect(request.getHeader("username")).andReturn("admin").times(2);
PowerMock.replayAll();
ruleMgtResources.addCorrelationRule(request, ruleCreateRequest);
PowerMock.verifyAll();
@@ -89,7 +89,7 @@ public class RuleMgtResourcesTest { final RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();
EasyMock.expect(ruleMgtWrapper.updateCorrelationRule("admin", ruleUpdateRequest))
.andThrow(new CorrelationException(EasyMock.anyObject(String.class)));
- EasyMock.expect(request.getHeader("username")).andReturn("admin");
+ EasyMock.expect(request.getHeader("username")).andReturn("admin").times(2);
PowerMock.replayAll();
ruleMgtResources.updateCorrelationRule(request, ruleUpdateRequest);
PowerMock.verifyAll();
@@ -100,7 +100,7 @@ public class RuleMgtResourcesTest { final RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();
EasyMock.expect(ruleMgtWrapper.updateCorrelationRule("admin",
ruleUpdateRequest)).andReturn(new RuleAddAndUpdateResponse());
- EasyMock.expect(request.getHeader("username")).andReturn("admin");
+ EasyMock.expect(request.getHeader("username")).andReturn("admin").times(2);
PowerMock.replayAll();
ruleMgtResources.updateCorrelationRule(request, ruleUpdateRequest);
PowerMock.verifyAll();
|