Skip to content

Commit

Permalink
Fixes HTTP Test (#250)
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Schnicke <frank.schnicke@iese.fraunhofer.de>
  • Loading branch information
FrankSchnicke committed Mar 21, 2023
1 parent ee9469a commit 8b5fa6a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public void createValue(String path, Object newValue) throws ProviderException {

private boolean isPropertyPathFileUploadPath(String propertyPath) {
String[] propertyPathParts = VABPathTools.splitPath(propertyPath);
boolean isFileUpload = VABPathTools.buildPath(propertyPathParts, 3).equals("upload");
boolean isFileUpload = VABPathTools.buildPath(propertyPathParts, 4).equals(UPLOAD);
return isFileUpload;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.eclipse.basyx.submodel.restapi.SubmodelAPIHelper;
import org.eclipse.basyx.submodel.restapi.api.ISubmodelAPI;
import org.eclipse.basyx.vab.exception.provider.MalformedRequestException;
import org.eclipse.basyx.vab.exception.provider.ProviderException;
import org.eclipse.basyx.vab.exception.provider.ResourceNotFoundException;
import org.eclipse.basyx.vab.modelprovider.VABElementProxy;
import org.eclipse.basyx.vab.modelprovider.api.IModelProvider;
Expand Down Expand Up @@ -131,7 +132,6 @@ public Collection<ISubmodelElement> getSubmodelElements() {
return elements.stream().map(SubmodelElement::createAsFacade).collect(Collectors.toList());
}

@SuppressWarnings("unchecked")
@Override
public void updateSubmodelElement(String idShortPath, Object newValue) {
getElementProvider().setValue(SubmodelAPIHelper.getSubmodelElementValuePath(idShortPath), newValue);
Expand All @@ -145,6 +145,7 @@ public void uploadSubmodelElementFile(String idShortPath, InputStream fileStream
try {
createFile(idShortPath, fileStream, submodelElement);
} catch (IOException e) {
throw new ProviderException(e);
}
} else {
throw new MalformedRequestException(
Expand Down Expand Up @@ -224,7 +225,7 @@ public java.io.File getSubmodelElementFile(String idShortPath) {
if (fileSubmodelElement.getValue().isEmpty()) {
throw new ResourceNotFoundException("The File Submodel Element does not contain a File");
}
return new java.io.File((String) fileSubmodelElement.getValue());
return new java.io.File(fileSubmodelElement.getValue());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,11 @@
* @author fried
*
*/
public class TestHTTPFileUpload {
public class TestHttpFileUpload {
private static final String SERVER = "localhost";
private static final int PORT = 4000;
private static final String CONTEXT_PATH = "fileSubmodelElementTest";
private static final String API_URL = "http://" + SERVER + ":" + PORT + "/" + CONTEXT_PATH + "/shells";
private static final Object HTTP_200 = "HTTP/1.1 200 ";
private static final Object HTTP_201 = "HTTP/1.1 201 ";
private static final Object HTTP_400 = "HTTP/1.1 400 ";
private AASAggregatorProvider provider = new AASAggregatorProvider(new AASAggregatorFactory().create());

@Rule
Expand Down Expand Up @@ -157,7 +154,6 @@ private CloseableHttpResponse uploadDummyAAS()
return client.execute(put);
}

@SuppressWarnings("unused")
private CloseableHttpResponse uploadDummySubmodel()
throws FileNotFoundException, IOException, UnsupportedEncodingException, ClientProtocolException {
File file = ResourceUtils.getFile("src/test/resources/aas/dummySubmodel.json");
Expand Down

0 comments on commit 8b5fa6a

Please sign in to comment.