Skip to content

Commit

Permalink
fix: temporarily fix AasService-client test. Refactor required.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShehriyarShariq-Fraunhofer committed May 31, 2024
1 parent 5d631dc commit b16451d
Showing 1 changed file with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import org.eclipse.digitaltwin.basyx.core.pagination.CursorResult;
import org.eclipse.digitaltwin.basyx.core.pagination.PaginationInfo;
import org.junit.Test;
import org.junit.Before;

/**
* Testsuite for implementations of the AasService interface
Expand All @@ -77,20 +76,6 @@ public abstract class AasServiceSuite {
private static final PaginationInfo NO_LIMIT_PAGINATION_INFO = new PaginationInfo(0, null);

protected abstract AasService getAasService(AssetAdministrationShell shell);

private FileRepository fileRepository;
private AasService aasServiceWithThumbnail;

@Before
public void setUp() throws IOException {
AssetAdministrationShell expected = DummyAssetAdministrationShellFactory.create();
aasServiceWithThumbnail = getAasService(expected);

FileMetadata defaultThumbnail = new FileMetadata("dummyImgA.jpeg", "", createDummyImageIS_A());
fileRepository = new InMemoryFileRepository();

setAasThumbnail(defaultThumbnail, fileRepository, aasServiceWithThumbnail);
}

@Test
public void getAas() {
Expand Down Expand Up @@ -178,6 +163,10 @@ public void getPaginatedSubmodelReferencesPaginated() {

@Test
public void updateThumbnail() throws FileNotFoundException, IOException {
Object[] setup = thumbnailSetUp();
FileRepository fileRepository = (FileRepository) setup[0];
AasService aasServiceWithThumbnail = (AasService) setup[1];

setAasThumbnail(
new FileMetadata("dummyImgB.jpeg", "", createDummyImageIS_B()),
fileRepository,
Expand Down Expand Up @@ -206,6 +195,9 @@ public void setThumbnail() throws FileNotFoundException, IOException {

@Test
public void getThumbnail() throws IOException {
Object[] setup = thumbnailSetUp();
AasService aasServiceWithThumbnail = (AasService) setup[1];

InputStream actualThumbnailIs = new FileInputStream(aasServiceWithThumbnail.getThumbnail());;

InputStream expectedThumbnail = createDummyImageIS_A();
Expand All @@ -223,6 +215,9 @@ public void getNonExistingThumbnail() {

@Test
public void deleteThumbnail() throws FileNotFoundException, IOException {
Object[] setup = thumbnailSetUp();
AasService aasServiceWithThumbnail = (AasService) setup[1];

aasServiceWithThumbnail.deleteThumbnail();

try {
Expand All @@ -239,6 +234,18 @@ public void deleteNonExistingThumbnail() throws IOException {

aasService.deleteThumbnail();
}

private Object[] thumbnailSetUp() throws IOException {
AssetAdministrationShell expected = DummyAssetAdministrationShellFactory.create();
AasService aasServiceWithThumbnail = getAasService(expected);

FileMetadata defaultThumbnail = new FileMetadata("dummyImgA.jpeg", "", createDummyImageIS_A());
FileRepository fileRepository = new InMemoryFileRepository();

setAasThumbnail(defaultThumbnail, fileRepository, aasServiceWithThumbnail);

return new Object[]{fileRepository, aasServiceWithThumbnail};
}

private AssetInformation createDummyAssetInformation() {
AssetInformation assetInfo = new DefaultAssetInformation.Builder().assetKind(AssetKind.INSTANCE)
Expand Down Expand Up @@ -281,7 +288,7 @@ private void setAasThumbnail(FileMetadata thumbnail, FileRepository repo, AasSer
aas.setAssetInformation(defaultAasAssetInformation);
}

private static InputStream createDummyImageIS_A() throws IOException {
public static InputStream createDummyImageIS_A() throws IOException {
return createDummyImageIS(0x000000);
}

Expand Down

0 comments on commit b16451d

Please sign in to comment.