/*-
* ============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.
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;
@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) {
/*-
* ============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");
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;
@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));
}
}
"modelInvariantId": "e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e",
"modelVersionId": "94b18b1d-cc91-4f43-911a-e6348665f292",
"modelName": "VfwclVfwsnkBbefb8ce2bde..base_vfw..module-0",
- "modelVersion": 1,
+ "modelVersion": "1",
"modelCustomizationId": "47958575-138f-452a-8c8d-d89b595f8164"
}
},
modelInvariantId: e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e
modelVersionId: 94b18b1d-cc91-4f43-911a-e6348665f292
modelName: VfwclVfwsnkBbefb8ce2bde..base_vfw..module-0
- modelVersion: 1
+ modelVersion: "1"
modelCustomizationId: 47958575-138f-452a-8c8d-d89b595f8164
payload:
requestParameters: '{"usePreload":true,"userParams":[]}'
"modelInvariantId": "e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e",
"modelVersionId": "94b18b1d-cc91-4f43-911a-e6348665f292",
"modelName": "VfwclVfwsnkBbefb8ce2bde..base_vfw..module-0",
- "modelVersion": 1,
+ "modelVersion": "1",
"modelCustomizationId": "47958575-138f-452a-8c8d-d89b595f8164"
}
},
modelInvariantId: e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e
modelVersionId: 94b18b1d-cc91-4f43-911a-e6348665f292
modelName: VfwclVfwsnkBbefb8ce2bde..base_vfw..module-0
- modelVersion: 1
+ modelVersion: "1"
modelCustomizationId: 47958575-138f-452a-8c8d-d89b595f8164
payload:
requestParameters: '{"usePreload":true,"userParams":[]}'
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.fail;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
@Test
public void testSerialization() {
- try {
+ assertThatCode(() -> {
// vCPE
JpaToscaServiceTemplate serviceTemplate = deserializeMonitoringInputJson(VCPE_MON_INPUT_JSON);
String serializedServiceTemplate = serializeMonitoringServiceTemplate(serviceTemplate);
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 {