* ============LICENSE_START=======================================================
* ONAP Policy API
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* 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.api.main.rest;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
import java.util.UUID;
-
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.ResponseBuilder;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.springframework.http.ResponseEntity;
/**
* Class to perform unit testing of CommonRestController.
*/
-public class TestCommonRestController {
- private CommonRestController crc = new CommonRestController();
+class TestCommonRestController {
+ private final CommonRestController crc = new CommonRestController();
@Test
- public void testAddLoggingHeaders() {
+ void testAddLoggingHeaders() {
UUID requestId = UUID.randomUUID();
- ResponseBuilder rb =
- crc.addLoggingHeaders(crc.addVersionControlHeaders(Response.status(Response.Status.OK)), requestId);
- assertTrue(rb.equals(rb.header("X-ONAP-RequestID", requestId)));
+ ResponseEntity<Void> rb = crc.makeOkResponse(requestId, null);
+ Assertions.assertEquals(requestId.toString(), rb.getHeaders().getFirst("X-ONAP-RequestID"));
}
/*
* Tests null response for null object
*/
@Test
- public void testToJsonNull() {
- assertNull(crc.toJson(null));
+ void testToJsonNull() {
+ Assertions.assertNull(crc.toJson(null));
}
-}
+}
\ No newline at end of file