* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END============================================
+ * Modifications copyright (c) 2018 Nokia
* ===================================================================
*
*/
package org.onap.clamp.clds.model;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
public class CldsDbServiceCacheTest {
@Test
public void testConstructor() throws IOException, ClassNotFoundException {
+ // given
CldsServiceData cldsServiceData = new CldsServiceData();
cldsServiceData.setServiceUUID("testUUID");
- cldsServiceData.setAgeOfRecord(Long.valueOf(100));
+ cldsServiceData.setAgeOfRecord(100L);
cldsServiceData.setServiceInvariantUUID("testInvariantUUID");
+
CldsVfData cldsVfData = new CldsVfData();
cldsVfData.setVfName("vf");
+
CldsVfKPIData cldsVfKpiData = new CldsVfKPIData();
cldsVfKpiData.setFieldPath("fieldPath");
cldsVfKpiData.setFieldPathValue("fieldValue");
+
List<CldsVfKPIData> cldsKpiList = new ArrayList<>();
cldsKpiList.add(cldsVfKpiData);
cldsVfData.setCldsKPIList(cldsKpiList);
+
List<CldsVfData> cldsVfs = new ArrayList<>();
cldsVfs.add(cldsVfData);
cldsServiceData.setCldsVfs(cldsVfs);
+
CldsDbServiceCache cldsDbServiceCache = new CldsDbServiceCache(cldsServiceData);
+
+ // when
ObjectInputStream reader = new ObjectInputStream(cldsDbServiceCache.getCldsDataInstream());
CldsServiceData cldsServiceDataResult = (CldsServiceData) reader.readObject();
- assertNotNull(cldsServiceDataResult);
- assertNotNull(cldsServiceDataResult.getCldsVfs());
- assertEquals(cldsServiceDataResult.getCldsVfs().size(), 1);
- assertNotNull(cldsServiceDataResult.getCldsVfs().get(0).getCldsKPIList());
- assertEquals(cldsServiceDataResult.getCldsVfs().get(0).getCldsKPIList().size(), 1);
- assertEquals(cldsServiceDataResult.getServiceInvariantUUID(), "testInvariantUUID");
- assertEquals(cldsServiceDataResult.getServiceUUID(), "testUUID");
- assertEquals(cldsServiceDataResult.getAgeOfRecord(), Long.valueOf(100L));
+
+ // then
+ assertThat(cldsServiceDataResult).isNotNull();
+ assertThat(cldsServiceDataResult.getCldsVfs()).hasSize(1);
+ assertThat(cldsServiceDataResult.getCldsVfs().get(0).getCldsKPIList()).hasSize(1);
+
+ assertThat(cldsServiceDataResult.getServiceInvariantUUID()).isEqualTo("testInvariantUUID");
+ assertThat(cldsServiceDataResult.getServiceUUID()).isEqualTo("testUUID");
+ assertThat(cldsServiceDataResult.getAgeOfRecord()).isEqualTo(100L);
}
}