From b24a4f2f4edf845c10ef42545496256b0bdbb8a8 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Tue, 11 Oct 2022 14:20:40 +0100 Subject: Fix response of fetch data type endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The catalog endpoint /v1/catalog/data-types/ is returning an Optional instead of the Data Type itself. Improves unit test to verify the response payload. Change-Id: I781917fb66225abf911a043370917e7b7a183bb1 Issue-ID: SDC-4211 Signed-off-by: André Schmid --- .../java/org/openecomp/sdc/be/servlets/DataTypeServletTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'catalog-be/src/test') diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/DataTypeServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/DataTypeServletTest.java index 39ba071a74..d916fffc12 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/DataTypeServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/DataTypeServletTest.java @@ -98,8 +98,10 @@ class DataTypeServletTest extends JerseySpringBaseTest { @Test void fetchDataTypeTest_Success() { + final DataTypeDataDefinition expectedDataType = new DataTypeDataDefinition(); + expectedDataType.setUniqueId(DATA_TYPE_UID); when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(new ResponseFormat(HttpStatus.SC_OK)); - when(dataTypeOperation.getDataTypeByUid(DATA_TYPE_UID)).thenReturn(Optional.of(new DataTypeDataDefinition())); + when(dataTypeOperation.getDataTypeByUid(DATA_TYPE_UID)).thenReturn(Optional.of(expectedDataType)); final Response response = target() .path(PATH) @@ -108,6 +110,8 @@ class DataTypeServletTest extends JerseySpringBaseTest { .get(Response.class); assertNotNull(response); assertEquals(HttpStatus.SC_OK, response.getStatus()); + final DataTypeDataDefinition actualDataType = response.readEntity(DataTypeDataDefinition.class); + assertEquals(expectedDataType.getUniqueId(), actualDataType.getUniqueId()); } @Test -- cgit 1.2.3-korg