From c54ef7f3a01b8b95f36ddba8c5bbb6577fcb607d Mon Sep 17 00:00:00 2001 From: Kenny Colliander Date: Sun, 6 Aug 2023 23:17:02 +0200 Subject: [PATCH] Added tests for copy constructor --- .../se/kecon/kalbum/AlbumContentTest.java | 41 +++++++++++++ src/test/java/se/kecon/kalbum/AlbumTest.java | 57 +++++++++++++++++++ .../java/se/kecon/kalbum/ContentDataTest.java | 53 +++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 src/test/java/se/kecon/kalbum/AlbumContentTest.java create mode 100644 src/test/java/se/kecon/kalbum/AlbumTest.java create mode 100644 src/test/java/se/kecon/kalbum/ContentDataTest.java diff --git a/src/test/java/se/kecon/kalbum/AlbumContentTest.java b/src/test/java/se/kecon/kalbum/AlbumContentTest.java new file mode 100644 index 0000000..2eada46 --- /dev/null +++ b/src/test/java/se/kecon/kalbum/AlbumContentTest.java @@ -0,0 +1,41 @@ +/** + * Kalbum + *

+ * Copyright 2023 Kenny Colliander + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package se.kecon.kalbum; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test {@link AlbumContent} + *

+ * Created 2023-08-06 by Kenny Colliander + */ +class AlbumContentTest { + + @Test + void testCopyConstructor() { + AlbumContent albumContent = new AlbumContent(); + albumContent.setId("id"); + albumContent.setName("name"); + + AlbumContent albumContentCopy = new AlbumContent(albumContent); + assertEquals(albumContent.getId(), albumContentCopy.getId()); + assertEquals(albumContent.getName(), albumContentCopy.getName()); + } +} \ No newline at end of file diff --git a/src/test/java/se/kecon/kalbum/AlbumTest.java b/src/test/java/se/kecon/kalbum/AlbumTest.java new file mode 100644 index 0000000..5c7a421 --- /dev/null +++ b/src/test/java/se/kecon/kalbum/AlbumTest.java @@ -0,0 +1,57 @@ +/** + * Kalbum + *

+ * Copyright 2023 Kenny Colliander + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package se.kecon.kalbum; + +import org.junit.jupiter.api.Test; + +import java.time.Instant; +import java.util.Collections; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test {@link Album} + *

+ * Created 2023-08-06 by Kenny Colliander + */ +class AlbumTest { + + @Test + void testCopyConstructor() { + ContentData contentData = new ContentData(); + contentData.setContentType("contentType"); + contentData.setSrc("src"); + contentData.setAlt("alt"); + contentData.setText("text"); + contentData.setWidth(1); + contentData.setHeight(2); + contentData.setTimestamp(Instant.now()); + + + Album album = new Album(); + album.setId("id"); + album.setName("name"); + album.setContents(Collections.singletonList(contentData)); + Album albumCopy = new Album(album); + assertEquals(album.getId(), albumCopy.getId()); + assertEquals(album.getName(), albumCopy.getName()); + assertEquals(album.getContents(), albumCopy.getContents()); + assertNotSame(album.getContents(), albumCopy.getContents()); + assertEquals(album.getContents().get(0), albumCopy.getContents().get(0)); + } +} \ No newline at end of file diff --git a/src/test/java/se/kecon/kalbum/ContentDataTest.java b/src/test/java/se/kecon/kalbum/ContentDataTest.java new file mode 100644 index 0000000..79a68dd --- /dev/null +++ b/src/test/java/se/kecon/kalbum/ContentDataTest.java @@ -0,0 +1,53 @@ +/** + * Kalbum + *

+ * Copyright 2023 Kenny Colliander + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package se.kecon.kalbum; + +import org.junit.jupiter.api.Test; + +import java.time.Instant; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Test {@link ContentData} + *

+ * Created 2023-08-06 by Kenny Colliander + */ +class ContentDataTest { + + @Test + void testCopyConstructor() { + ContentData contentData = new ContentData(); + contentData.setContentType("contentType"); + contentData.setSrc("src"); + contentData.setAlt("alt"); + contentData.setText("text"); + contentData.setWidth(1); + contentData.setHeight(2); + contentData.setTimestamp(Instant.now()); + + ContentData contentDataCopy = new ContentData(contentData); + assertEquals(contentData.getContentType(), contentDataCopy.getContentType()); + assertEquals(contentData.getSrc(), contentDataCopy.getSrc()); + assertEquals(contentData.getAlt(), contentDataCopy.getAlt()); + assertEquals(contentData.getText(), contentDataCopy.getText()); + assertEquals(contentData.getWidth(), contentDataCopy.getWidth()); + assertEquals(contentData.getHeight(), contentDataCopy.getHeight()); + assertEquals(contentData.getTimestamp(), contentDataCopy.getTimestamp()); + } +} \ No newline at end of file