Skip to content

Commit

Permalink
Added tests for copy constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Kecon committed Aug 6, 2023
1 parent 320d9cd commit c54ef7f
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/test/java/se/kecon/kalbum/AlbumContentTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Kalbum
* <p>
* Copyright 2023 Kenny Colliander
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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}
* <p>
* 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());
}
}
57 changes: 57 additions & 0 deletions src/test/java/se/kecon/kalbum/AlbumTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Kalbum
* <p>
* Copyright 2023 Kenny Colliander
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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}
* <p>
* 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));
}
}
53 changes: 53 additions & 0 deletions src/test/java/se/kecon/kalbum/ContentDataTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Kalbum
* <p>
* Copyright 2023 Kenny Colliander
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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}
* <p>
* 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());
}
}

0 comments on commit c54ef7f

Please sign in to comment.