Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit481f162

Browse files
Thomasludomikula
Thomas
authored andcommitted
Fix issues add/move app
add test case for getPublishedBundle
1 parent58f13a4 commit481f162

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/bundle/BundleApiServiceImpl.java‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,15 @@ public Mono<Void> moveApp(String applicationId, String fromBundleId, String toBu
268268
if (StringUtils.isBlank(toBundleId)) {
269269
returnMono.empty();
270270
}
271-
returnbundleService.findById(fromBundleId).map(bundle -> {
271+
returnbundleService.findById(fromBundleId).flatMap(bundle -> {
272272
varmap =bundle.getEditingBundleDSL();
273273
if(map ==null)map =newHashMap<>();
274-
((List<Application>)map.computeIfAbsent("applications",k->newArrayList<>())).removeIf(app ->app.getId() ==applicationId);
274+
((List<Application>)map.computeIfAbsent("applications",k->newArrayList<>())).removeIf(app ->app.getId().equals(applicationId));
275275
bundle.setEditingBundleDSL(map);
276-
returnbundle;
277-
}).map(bundle ->applicationRepository.findById(applicationId)
276+
returnbundleRepository.save(bundle);
277+
})
278+
.then(bundleRepository.findById(toBundleId))
279+
.flatMap(bundle ->applicationRepository.findById(applicationId)
278280
.flatMap(newapplication ->addAppToBundle(bundle,newapplication)))
279281
.then(bundleElementRelationService.create(toBundleId,applicationId));
280282
})
@@ -305,7 +307,7 @@ public Mono<Void> addApp(String applicationId, String toBundleId) {
305307
if (StringUtils.isBlank(toBundleId)) {
306308
returnMono.empty();
307309
}
308-
returnbundleService.findById(toBundleId).map(bundle ->applicationRepository.findById(applicationId)
310+
returnbundleService.findById(toBundleId).flatMap(bundle ->applicationRepository.findById(applicationId)
309311
.flatMap(newapplication->addAppToBundle(bundle,newapplication)))
310312
.then(bundleElementRelationService.create(toBundleId,applicationId));
311313
})
@@ -368,7 +370,6 @@ public Mono<BundleInfoView> getPublishedBundle(String bundleId, BundleRequestTyp
368370
.category(bundle.getCategory())
369371
.description(bundle.getDescription())
370372
.image(bundle.getImage())
371-
// .editingBundleDSL(bundle.getEditingBundleDSL())
372373
.publishedBundleDSL(bundle.getPublishedBundleDSL())
373374
.publicToMarketplace(bundle.getPublicToMarketplace())
374375
.publicToAll(bundle.getPublicToAll())

‎server/api-service/lowcoder-server/src/test/java/org/lowcoder/api/bundle/BundleApiServiceImplTest.java‎

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
importorg.junit.runner.RunWith;
55
importorg.lowcoder.api.bundle.view.BundleInfoView;
66
importorg.lowcoder.api.home.SessionUserServiceImpl;
7+
importorg.lowcoder.domain.bundle.model.BundleRequestType;
78
importorg.lowcoder.domain.organization.model.MemberRole;
89
importorg.lowcoder.domain.organization.model.OrgMember;
910
importorg.springframework.beans.factory.annotation.Autowired;
@@ -117,24 +118,31 @@ public void moveAddAppTest() {
117118
"image",
118119
null));
119120

120-
StepVerifier.create(Mono.zip(bundleInfoViewMono,bundleInfoViewMono2))
121-
.assertNext(tuple2 -> {
121+
Mono<Void>testMono =Mono.zip(bundleInfoViewMono,bundleInfoViewMono2)
122+
.flatMap(tuple2 -> {
122123
varbundleInfoView =tuple2.getT1();
123124
varbundleInfoView2 =tuple2.getT2();
124-
//And then add app01 to created bundle
125-
StepVerifier.create(bundleApiService.addApp("app01",bundleInfoView.getBundleId()))
126-
.verifyComplete();
127-
//or move bundle
128-
StepVerifier.create(bundleApiService.moveApp("app01",bundleInfoView.getBundleId(),bundleInfoView2.getBundleId()))
129-
.verifyComplete();
130-
//Try no dev user to add app to bundle
131-
when(sessionUserService.getVisitorId()).thenReturn(Mono.just("user01"));
132-
when(sessionUserService.getVisitorOrgMemberCache()).thenReturn(Mono.just(newOrgMember("org01","user01",MemberRole.MEMBER,"NORMAL",0)));
133-
StepVerifier.create(bundleApiService.addApp("app01",bundleInfoView.getBundleId()))
134-
.expectError();
135-
StepVerifier.create(bundleApiService.moveApp("app01",bundleInfoView.getBundleId(),bundleInfoView2.getBundleId()))
136-
.expectError();
137-
})
125+
126+
returnbundleApiService.addApp("app01",bundleInfoView.getBundleId())
127+
.then(bundleApiService.moveApp("app01",bundleInfoView.getBundleId(),bundleInfoView2.getBundleId()))
128+
.then(Mono.fromRunnable(() -> {
129+
// Try a no-dev user to add app to bundle
130+
when(sessionUserService.getVisitorId()).thenReturn(Mono.just("user01"));
131+
when(sessionUserService.getVisitorOrgMemberCache()).thenReturn(Mono.just(newOrgMember("org01","user01",MemberRole.MEMBER,"NORMAL",0)));
132+
}))
133+
.then(bundleApiService.addApp("app01",bundleInfoView.getBundleId()).onErrorResume(e ->Mono.empty()))
134+
.then(bundleApiService.moveApp("app01",bundleInfoView.getBundleId(),bundleInfoView2.getBundleId()).onErrorResume(e ->Mono.empty()))
135+
//Get published bundle
136+
.then(bundleApiService.getPublishedBundle(bundleInfoView2.getBundleId(),BundleRequestType.PUBLIC_TO_ALL))
137+
.doOnNext(bundle -> {
138+
//should have no published dsl since not yet published
139+
assertNotNull(bundle.getBundleId());
140+
assertNull(bundle.getPublishedBundleDSL());
141+
})
142+
.then();
143+
});
144+
145+
StepVerifier.create(testMono)
138146
.verifyComplete();
139147
}
140148
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp