Skip to content
This repository was archived by the owner on Apr 15, 2021. It is now read-only.

Commit 8a4a5a5

Browse files
committed
Merge the current master to GitHub
1 parent d6bf739 commit 8a4a5a5

File tree

5 files changed

+151
-15
lines changed

5 files changed

+151
-15
lines changed

oscm-internal/javasrc/org/oscm/internal/assembler/POLandingpageEntryAssembler.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
import org.oscm.domobjects.TechnicalProductOperation;
2121
import org.oscm.domobjects.enums.LocalizedObjectTypes;
2222
import org.oscm.i18nservice.bean.LocalizerFacade;
23-
import org.oscm.serviceprovisioningservice.assembler.ProductAssembler;
2423
import org.oscm.internal.landingpage.POLandingpageEntry;
2524
import org.oscm.internal.types.enumtypes.OrganizationRoleType;
2625
import org.oscm.internal.types.enumtypes.ServiceType;
26+
import org.oscm.serviceprovisioningservice.assembler.ProductAssembler;
2727

2828
/**
2929
* Assembler that merges service and subscription into PO object
@@ -142,8 +142,8 @@ protected static void updateEntryForSubscription(Subscription subscription,
142142
entry.setSubscribed(true);
143143
}
144144

145-
static void setServiceAccessUrl(Subscription subscription, POLandingpageEntry entry,
146-
TechnicalProduct techProd) {
145+
static void setServiceAccessUrl(Subscription subscription,
146+
POLandingpageEntry entry, TechnicalProduct techProd) {
147147
if (subscription.getBaseURL() == null) {
148148
entry.setServiceAccessURL(techProd.getBaseURL());
149149
} else {
@@ -178,7 +178,7 @@ private static void prefetchForPoducts(List<Product> products,
178178
LocalizerFacade facade) {
179179
List<Long> objectKeys = new ArrayList<Long>();
180180
for (Product product : products) {
181-
objectKeys.add(Long.valueOf(product.getKey()));
181+
objectKeys.add(Long.valueOf(product.getTemplateOrSelf().getKey()));
182182
}
183183
facade.prefetch(
184184
objectKeys,

oscm-internalservices-unittests/javasrc/org/oscm/internal/assembler/POLandingpageEntryAssemblerTest.java

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,40 @@
88

99
package org.oscm.internal.assembler;
1010

11+
import static org.junit.Assert.assertEquals;
12+
import static org.junit.Assert.assertThat;
13+
import static org.junit.Assert.assertTrue;
14+
import static org.mockito.Mockito.spy;
15+
import static org.mockito.Mockito.times;
16+
import static org.mockito.Mockito.verify;
1117
import static org.oscm.test.Numbers.L_TIMESTAMP;
1218
import static org.oscm.test.matchers.JavaMatchers.hasNoItems;
1319
import static org.oscm.test.matchers.JavaMatchers.hasOneItem;
1420
import static org.oscm.test.matchers.JavaMatchers.isNullValue;
15-
import static org.junit.Assert.assertEquals;
16-
import static org.junit.Assert.assertThat;
17-
import static org.junit.Assert.assertTrue;
1821

1922
import java.util.ArrayList;
2023
import java.util.Arrays;
2124
import java.util.List;
2225

2326
import org.junit.Before;
2427
import org.junit.Test;
25-
28+
import org.mockito.ArgumentCaptor;
29+
import org.mockito.Captor;
30+
import org.mockito.Matchers;
31+
import org.mockito.MockitoAnnotations;
2632
import org.oscm.domobjects.Organization;
2733
import org.oscm.domobjects.PlatformUser;
2834
import org.oscm.domobjects.Product;
2935
import org.oscm.domobjects.Subscription;
3036
import org.oscm.domobjects.TechnicalProduct;
3137
import org.oscm.domobjects.enums.LocalizedObjectTypes;
3238
import org.oscm.i18nservice.bean.LocalizerFacade;
33-
import org.oscm.test.stubs.LocalizerServiceStub;
3439
import org.oscm.internal.landingpage.POLandingpageEntry;
3540
import org.oscm.internal.types.enumtypes.ServiceAccessType;
3641
import org.oscm.internal.types.enumtypes.ServiceStatus;
3742
import org.oscm.internal.types.enumtypes.ServiceType;
3843
import org.oscm.internal.types.enumtypes.SubscriptionStatus;
44+
import org.oscm.test.stubs.LocalizerServiceStub;
3945

4046
/**
4147
* @author zankov
@@ -44,6 +50,8 @@
4450
public class POLandingpageEntryAssemblerTest {
4551

4652
private LocalizerFacade facade;
53+
@Captor
54+
ArgumentCaptor<List<Long>> objectKeyCaptor;
4755

4856
@Before
4957
public void setup() throws Exception {
@@ -55,6 +63,8 @@ public String getLocalizedTextFromDatabase(String localeString,
5563
return objectType.name();
5664
}
5765
}, "en");
66+
67+
MockitoAnnotations.initMocks(this);
5868
}
5969

6070
private Organization givenSupplier() {
@@ -261,4 +271,69 @@ private Subscription givenSubscription(String subId, ServiceAccessType type) {
261271
subscription.setOwner(owner);
262272
return subscription;
263273
}
274+
275+
@Test
276+
public void toPOLandingpageEntries_prefetchForPoducts_withoutTemplates_bug12479() {
277+
// given
278+
List<Subscription> subscriptions = Arrays.asList(
279+
givenSubscription("sub_1", ServiceAccessType.LOGIN),
280+
givenSubscription("sub_2", ServiceAccessType.LOGIN));
281+
List<Product> services = Arrays
282+
.asList(givenProduct(ServiceAccessType.LOGIN));
283+
LocalizerFacade facadeMock = spy(facade);
284+
285+
// when
286+
POLandingpageEntryAssembler.toPOLandingpageEntries(services,
287+
subscriptions, facadeMock);
288+
289+
// than
290+
verify(facadeMock, times(2)).prefetch(objectKeyCaptor.capture(),
291+
Matchers.anyListOf(LocalizedObjectTypes.class));
292+
List<List<Long>> args = objectKeyCaptor.getAllValues();
293+
List<Long> objectkeys = args.get(0);
294+
assertEquals(1, objectkeys.size());
295+
assertEquals(Long.valueOf(4321), objectkeys.get(0));
296+
}
297+
298+
@Test
299+
public void toPOLandingpageEntries_prefetchForPoducts_withTemplates_bug12479() {
300+
// given
301+
List<Subscription> subscriptions = Arrays.asList(
302+
givenSubscription("sub_1", ServiceAccessType.LOGIN),
303+
givenSubscription("sub_2", ServiceAccessType.LOGIN));
304+
List<Product> services = new ArrayList<Product>();
305+
services.add(givenProduct(ServiceAccessType.LOGIN));
306+
Product template = new Product();
307+
template.setType(ServiceType.TEMPLATE);
308+
template.setVendor(givenSupplier());
309+
template.setTechnicalProduct(givenTechnicalProduct(ServiceAccessType.LOGIN));
310+
template.setKey(4322);
311+
template.setProductId("template");
312+
template.setStatus(ServiceStatus.ACTIVE);
313+
services.add(template);
314+
Product product = new Product();
315+
product.setType(ServiceType.TEMPLATE);
316+
product.setVendor(givenSupplier());
317+
product.setTechnicalProduct(givenTechnicalProduct(ServiceAccessType.LOGIN));
318+
product.setKey(4323);
319+
product.setProductId("product");
320+
product.setStatus(ServiceStatus.ACTIVE);
321+
product.setTemplate(template);
322+
services.add(product);
323+
LocalizerFacade facadeMock = spy(facade);
324+
325+
// when
326+
POLandingpageEntryAssembler.toPOLandingpageEntries(services,
327+
subscriptions, facadeMock);
328+
329+
// than
330+
verify(facadeMock, times(2)).prefetch(objectKeyCaptor.capture(),
331+
Matchers.anyListOf(LocalizedObjectTypes.class));
332+
List<List<Long>> args = objectKeyCaptor.getAllValues();
333+
List<Long> objectkeys = args.get(0);
334+
assertEquals(3, objectkeys.size());
335+
assertEquals(Long.valueOf(4321), objectkeys.get(0));
336+
assertEquals(Long.valueOf(4322), objectkeys.get(1));
337+
assertEquals(Long.valueOf(4322), objectkeys.get(2));
338+
}
264339
}

oscm-portal-webtests/tests/marketplace/allTests.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<ant antfile="./marketplace/testTags.xml" />
1717
<ant antfile="./marketplace/testPaging.xml" />
1818
<ant antfile="./marketplace/testConfigurableMarketplaces.xml" />
19-
<ant antfile="./marketplace/testServiceVisibility.xml" />
19+
<!-- <ant antfile="./marketplace/testServiceVisibility.xml" /> -->
2020
<ant antfile="./marketplace/testFeedbackRating.xml" />
2121
<ant antfile="./marketplace/testSingleSubscription.xml" />
2222
<ant antfile="./marketplace/testSubscriptionDetail.xml" />

oscm-serviceprovisioning-intsvc/javasrc/org/oscm/serviceprovisioningservice/assembler/ProductAssembler.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
import org.oscm.domobjects.enums.LocalizedObjectTypes;
3131
import org.oscm.i18nservice.bean.LocalizerFacade;
3232
import org.oscm.interceptor.DateFactory;
33-
import org.oscm.validator.BLValidator;
34-
import org.oscm.vo.BaseAssembler;
3533
import org.oscm.internal.types.enumtypes.OfferingType;
3634
import org.oscm.internal.types.enumtypes.OrganizationRoleType;
3735
import org.oscm.internal.types.enumtypes.PerformanceHint;
@@ -48,6 +46,8 @@
4846
import org.oscm.internal.vo.VOServiceDetails;
4947
import org.oscm.internal.vo.VOServiceEntry;
5048
import org.oscm.internal.vo.VOTechnicalService;
49+
import org.oscm.validator.BLValidator;
50+
import org.oscm.vo.BaseAssembler;
5151

5252
/**
5353
* @author G&uuml;nther Schmid
@@ -270,7 +270,8 @@ public static void prefetchData(List<Product> products,
270270
if (scope == PerformanceHint.ONLY_FIELDS_FOR_LISTINGS) {
271271
List<Long> objectKeys = new ArrayList<Long>();
272272
for (Product product : products) {
273-
objectKeys.add(Long.valueOf(product.getKey()));
273+
objectKeys.add(Long.valueOf(product.getTemplateOrSelf()
274+
.getKey()));
274275
}
275276
facade.prefetch(
276277
objectKeys,

oscm-serviceprovisioning-unittests/javasrc/org/oscm/serviceprovisioningservice/assembler/ProductAssemblerTest.java

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import static org.junit.Assert.assertEquals;
1616
import static org.junit.Assert.assertNull;
1717
import static org.junit.Assert.assertTrue;
18+
import static org.mockito.Mockito.spy;
19+
import static org.mockito.Mockito.times;
20+
import static org.mockito.Mockito.verify;
1821

1922
import java.math.BigDecimal;
2023
import java.util.ArrayList;
@@ -27,7 +30,10 @@
2730
import org.junit.Assert;
2831
import org.junit.Before;
2932
import org.junit.Test;
30-
33+
import org.mockito.ArgumentCaptor;
34+
import org.mockito.Captor;
35+
import org.mockito.Matchers;
36+
import org.mockito.MockitoAnnotations;
3137
import org.oscm.domobjects.Event;
3238
import org.oscm.domobjects.Organization;
3339
import org.oscm.domobjects.OrganizationRole;
@@ -47,7 +53,6 @@
4753
import org.oscm.domobjects.TechnicalProductTag;
4854
import org.oscm.domobjects.enums.LocalizedObjectTypes;
4955
import org.oscm.i18nservice.bean.LocalizerFacade;
50-
import org.oscm.test.stubs.LocalizerServiceStub;
5156
import org.oscm.internal.types.enumtypes.OrganizationRoleType;
5257
import org.oscm.internal.types.enumtypes.PerformanceHint;
5358
import org.oscm.internal.types.enumtypes.PriceModelType;
@@ -60,6 +65,7 @@
6065
import org.oscm.internal.vo.VOPricedParameter;
6166
import org.oscm.internal.vo.VOService;
6267
import org.oscm.internal.vo.VOServiceDetails;
68+
import org.oscm.test.stubs.LocalizerServiceStub;
6369

6470
/**
6571
* @author weiser
@@ -78,17 +84,24 @@ public class ProductAssemblerTest {
7884
private PlatformUser user;
7985
private VOService voService;
8086
private VOService voCustomerService;
87+
@Captor
88+
ArgumentCaptor<List<Long>> objectKeyCaptor;
8189

8290
@Before
8391
public void setup() throws Exception {
92+
8493
facade = new LocalizerFacade(new LocalizerServiceStub() {
8594

8695
@Override
8796
public String getLocalizedTextFromDatabase(String localeString,
8897
long objectKey, LocalizedObjectTypes objectType) {
98+
8999
return objectType.name();
90100
}
91101
}, "en");
102+
103+
MockitoAnnotations.initMocks(this);
104+
92105
technicalProduct = new TechnicalProduct();
93106
technicalProduct.setAccessType(ServiceAccessType.DIRECT);
94107
technicalProduct.setBaseURL("baseURL");
@@ -810,4 +823,51 @@ private void verifyCopiedAttributes(Product prod) {
810823
Boolean.valueOf(voService.isAutoAssignUserEnabled()));
811824
}
812825

826+
@Test
827+
public void prefetchData_withoutTemplates_bug12479() {
828+
// given
829+
List<Product> products = new ArrayList<Product>();
830+
products.add(product);
831+
products.add(customerProduct);
832+
LocalizerFacade facadeMock = spy(facade);
833+
834+
// when
835+
ProductAssembler.prefetchData(products, facadeMock,
836+
PerformanceHint.ONLY_FIELDS_FOR_LISTINGS);
837+
838+
// then
839+
verify(facadeMock, times(1)).prefetch(objectKeyCaptor.capture(),
840+
Matchers.anyListOf(LocalizedObjectTypes.class));
841+
List<Long> objectkeys = objectKeyCaptor.getValue();
842+
assertEquals(2, objectkeys.size());
843+
assertEquals(Long.valueOf(product.getKey()), objectkeys.get(0));
844+
assertEquals(Long.valueOf(customerProduct.getKey()), objectkeys.get(1));
845+
}
846+
847+
@Test
848+
public void prefetchData_withTemplates_bug12479() {
849+
// given
850+
List<Product> products = new ArrayList<Product>();
851+
products.add(product);
852+
Product anotherProduct = new Product();
853+
anotherProduct.setType(ServiceType.PARTNER_TEMPLATE);
854+
anotherProduct.setConfiguratorUrl("some value");
855+
anotherProduct.setTemplate(template);
856+
products.add(anotherProduct);
857+
products.add(customerProduct);
858+
LocalizerFacade facadeMock = spy(facade);
859+
860+
// when
861+
ProductAssembler.prefetchData(products, facadeMock,
862+
PerformanceHint.ONLY_FIELDS_FOR_LISTINGS);
863+
864+
// then
865+
verify(facadeMock, times(1)).prefetch(objectKeyCaptor.capture(),
866+
Matchers.anyListOf(LocalizedObjectTypes.class));
867+
List<Long> objectkeys = objectKeyCaptor.getValue();
868+
assertEquals(3, objectkeys.size());
869+
assertEquals(Long.valueOf(product.getKey()), objectkeys.get(0));
870+
assertEquals(Long.valueOf(template.getKey()), objectkeys.get(1));
871+
assertEquals(Long.valueOf(customerProduct.getKey()), objectkeys.get(2));
872+
}
813873
}

0 commit comments

Comments
 (0)