summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
860a08f)
Issue-ID: POLICY-2451
Change-Id: I095beb674196d5ec5c4dd9b93d3a56cca5ee4788
Signed-off-by: waynedunican <wayne.dunican@est.tech>
/*-
* ============LICENSE_START=======================================================
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.models.base;
package org.onap.policy.models.base;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import javax.ws.rs.core.Response;
import static org.junit.Assert.assertEquals;
import javax.ws.rs.core.Response;
import org.junit.Test;
import org.onap.policy.models.errors.concepts.ErrorResponseInfo;
import org.junit.Test;
import org.onap.policy.models.errors.concepts.ErrorResponseInfo;
@Test
public void testExceptionInfo() {
@Test
public void testExceptionInfo() {
- try {
- throw new PfModelException(Response.Status.ACCEPTED, "HELLO");
- } catch (PfModelException pfme) {
- String errorMessage = getErrorMessage(pfme);
- assertEquals("Server returned: Accepted", errorMessage.substring(0, 25));
- }
+ final PfModelException pfme = new PfModelException(Response.Status.ACCEPTED, "HELLO");
+ assertThat(pfme).hasMessage("HELLO");
+ assertEquals("Server returned: Accepted", getErrorMessage(pfme).substring(0, 25));
- try {
- throw new PfModelRuntimeException(Response.Status.ACCEPTED, "HELLO");
- } catch (PfModelRuntimeException pfme) {
- String errorMessage = getErrorMessage(pfme);
- assertEquals("Server returned: Accepted", errorMessage.substring(0, 25));
- }
+ final PfModelRuntimeException pfmr = new PfModelRuntimeException(Response.Status.ACCEPTED, "HELLO");
+ assertThat(pfmr).hasMessage("HELLO");
+ assertEquals("Server returned: Accepted", getErrorMessage(pfmr).substring(0, 25));
}
private String getErrorMessage(final ErrorResponseInfo eri) {
}
private String getErrorMessage(final ErrorResponseInfo eri) {
/*-
* ============LICENSE_START=======================================================
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.models.errors.concepts;
package org.onap.policy.models.errors.concepts;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.junit.Test;
/**
import org.junit.Test;
/**
@Test
public void testErrorResponseUtils() {
@Test
public void testErrorResponseUtils() {
- try {
- throw new IOException(EXCEPTION1, new NumberFormatException("Exception 0"));
- } catch (Exception ioe) {
- ErrorResponse errorResponse = new ErrorResponse();
- ErrorResponseUtils.getExceptionMessages(errorResponse, ioe);
+ final IOException ioe = new IOException(EXCEPTION1, new NumberFormatException("Exception 0"));
+ final ErrorResponse errorResponse = new ErrorResponse();
+ assertThat(ioe).hasMessage(EXCEPTION1);
- assertEquals(EXCEPTION1, errorResponse.getErrorMessage());
- assertEquals(EXCEPTION1, errorResponse.getErrorDetails().get(0));
- assertEquals("Exception 0", errorResponse.getErrorDetails().get(1));
- }
+ ErrorResponseUtils.getExceptionMessages(errorResponse, ioe);
+ assertEquals(EXCEPTION1, errorResponse.getErrorMessage());
+ assertEquals(EXCEPTION1, errorResponse.getErrorDetails().get(0));
+ assertEquals("Exception 0", errorResponse.getErrorDetails().get(1));
package org.onap.policy.models.tosca.simple.serialization;
package org.onap.policy.models.tosca.simple.serialization;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.junit.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.junit.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@Test
public void testSerialization() {
@Test
public void testSerialization() {
// vCPE
JpaToscaServiceTemplate serviceTemplate = deserializeMonitoringInputJson(VCPE_MON_INPUT_JSON);
String serializedServiceTemplate = serializeMonitoringServiceTemplate(serviceTemplate);
// vCPE
JpaToscaServiceTemplate serviceTemplate = deserializeMonitoringInputJson(VCPE_MON_INPUT_JSON);
String serializedServiceTemplate = serializeMonitoringServiceTemplate(serviceTemplate);
serializedServiceTemplate = serializeMonitoringServiceTemplate(serviceTemplate);
verifyVfwMonitoringOutputserialization(serializedServiceTemplate);
serializedServiceTemplate = serializeMonitoringServiceTemplate(serviceTemplate);
verifyVfwMonitoringOutputserialization(serializedServiceTemplate);
- } catch (Exception e) {
- LOGGER.warn("No exception should be thrown", e);
- fail("No exception should be thrown");
- }
+ }).as("No exception should be thrown").doesNotThrowAnyException();
}
private JpaToscaServiceTemplate deserializeMonitoringInputJson(String resourcePath) throws Exception {
}
private JpaToscaServiceTemplate deserializeMonitoringInputJson(String resourcePath) throws Exception {