Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ public void getAllAasWithIdShort() throws IOException, ParseException {
BaSyxHttpTestUtils.assertSameJSONContent(getPaginatedAas1JSONString(), getJSONWithoutCursorInfo(actualJsonFromServer));
}

@Test
public void getAllAasWithMultipleAssetIds() throws IOException, ParseException {
createMultipleAasOnServer();
CloseableHttpResponse retrievalResponse = getAllAasMultipleGlobalAssetIdsParam();
assertEquals(HttpStatus.OK.value(), retrievalResponse.getCode());

String actualJsonFromServer = BaSyxHttpTestUtils.getResponseAsString(retrievalResponse);
BaSyxHttpTestUtils.assertSameJSONContent(getEmptyResultJSONString(), getJSONWithoutCursorInfo(actualJsonFromServer));
}

@Test
public void deleteAas() throws IOException {
createDummyAasOnServer(getAas1JSONString());
Expand Down Expand Up @@ -423,6 +433,10 @@ public void deleteNonExistingThumbnail() throws FileNotFoundException, Unsupport
private String getPaginatedAas1JSONString() throws FileNotFoundException, IOException {
return BaSyxHttpTestUtils.readJSONStringFromClasspath("PaginatedAasSimple_1.json");
}

private String getEmptyResultJSONString() throws FileNotFoundException, IOException {
return BaSyxHttpTestUtils.readJSONStringFromClasspath("EmptyResponse.json");
}

private String getJSONWithoutCursorInfo(String response) throws JsonMappingException, JsonProcessingException {
return BaSyxHttpTestUtils.removeCursorFromJSON(response);
Expand Down Expand Up @@ -489,6 +503,10 @@ protected CloseableHttpResponse getAllAasGlobalAssetIdsParam() throws IOExceptio
return BaSyxHttpTestUtils.executeGetOnURL(getURL()+"?assetIds=ew0KIm5hbWUiOiJnbG9iYWxBc3NldElkIiwNCiJ2YWx1ZSI6Imdsb2JhbEFzc2V0SWQiDQp9");
}

protected CloseableHttpResponse getAllAasMultipleGlobalAssetIdsParam() throws IOException {
return BaSyxHttpTestUtils.executeGetOnURL(getURL()+"?assetIds=ew0KIm5hbWUiOiJnbG9iYWxBc3NldElkIiwNCiJ2YWx1ZSI6Imdsb2JhbEFzc2V0SWQiDQp9&assetIds=ew0KIm5hbWUiOiJnbG9iYWxBc3NldElkIiwNCiJ2YWx1ZSI6ImR1bW15QWFzQXNzZXRJZCINCn0");
}

protected CloseableHttpResponse getAllAasIdShortParam() throws IOException {
return BaSyxHttpTestUtils.executeGetOnURL(getURL()+"?idShort=ExampleMotor");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"paging_metadata": {},
"result": [
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public Iterable<AssetAdministrationShell> getAllAas(List<SpecificAssetId> assetI
List<AssetAdministrationShell> filteredAas = new java.util.ArrayList<>();
String globalAssetId = null;
try {
if(assetIds.stream().filter(assetId -> assetId.getName().equals("globalAssetId")).count() > 1){
return filteredAas;
}
globalAssetId = assetIds.stream().filter(assetId -> assetId.getName().equals("globalAssetId")).findFirst().get().getValue();
assetIds = assetIds.stream().filter(assetId -> !assetId.getName().equals("globalAssetId")).collect(Collectors.toList());
} catch (Exception e) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,10 @@ public Iterable<AssetAdministrationShell> getAllAas(List<SpecificAssetId> assetI
Query query = new Query();
Criteria criteria = new Criteria();

String globalAssetId = null;
try {
globalAssetId = assetIds.stream().filter(assetId -> assetId.getName().equals("globalAssetId")).findFirst().get().getValue();
assetIds = assetIds.stream().filter(assetId -> !assetId.getName().equals("globalAssetId")).collect(Collectors.toList());
} catch (Exception ignored) {}

List<String> globalAssetId = assetIds.stream()
.filter(assetId -> "globalAssetId".equals(assetId.getName()))
.map(SpecificAssetId::getValue)
.collect(Collectors.toList());
if (assetIds != null && !assetIds.isEmpty()) {
List<Criteria> assetIdCriteria = new ArrayList<>();
for (SpecificAssetId assetId : assetIds) {
Expand All @@ -195,8 +193,8 @@ public Iterable<AssetAdministrationShell> getAllAas(List<SpecificAssetId> assetI
}
query.addCriteria(criteria);

if (globalAssetId != null && !globalAssetId.isEmpty()) {
query.addCriteria(Criteria.where("assetInformation.globalAssetId").is(globalAssetId));
for (String id : globalAssetId) {
query.addCriteria(Criteria.where("assetInformation.globalAssetId").is(id));
}

return mongoOperations.find(query, AssetAdministrationShell.class, collectionName);
Expand Down
Loading