How to use Platform method of org.mockito.internal.util.Platform class

Best Mockito code snippet using org.mockito.internal.util.Platform.Platform

Source:IdentityServiceBeanUserDeletionTest.java Github

copy

Full Screen

...31import org.oscm.communicationservice.local.CommunicationServiceLocal;32import org.oscm.dataservice.local.DataService;33import org.oscm.domobjects.Marketplace;34import org.oscm.domobjects.Organization;35import org.oscm.domobjects.PlatformUser;36import org.oscm.domobjects.Session;37import org.oscm.domobjects.Subscription;38import org.oscm.reviewservice.bean.ReviewServiceLocalBean;39import org.oscm.sessionservice.local.SessionServiceLocal;40import org.oscm.subscriptionservice.local.SubscriptionServiceLocal;41import org.oscm.types.enumtypes.EmailType;42import org.oscm.internal.types.enumtypes.SubscriptionStatus;43import org.oscm.internal.types.exception.ConcurrentModificationException;44import org.oscm.internal.types.exception.IllegalArgumentException;45import org.oscm.internal.types.exception.ObjectNotFoundException;46import org.oscm.internal.types.exception.OperationNotPermittedException;47import org.oscm.internal.types.exception.UserDeletionConstraintException;48import org.oscm.internal.vo.VOUserDetails;49/**50 * The unit test for identityServiceBean.deleteUser51 * 52 * @author Gao53 * 54 */55public class IdentityServiceBeanUserDeletionTest {56 private static final String ORGANIZATION_ID = "ORG_ID";57 private static final String ORGANIZATION_NAME = "ORG_NANE";58 private IdentityServiceBean idMgmt;59 private DataService dm;60 private SubscriptionServiceLocal sm;61 private SessionServiceLocal sessionService;62 private SessionContext sessionCtx;63 private Principal principal;64 private ReviewServiceLocalBean rvs;65 private CommunicationServiceLocal cm;66 private VOUserDetails user;67 private PlatformUser userToBeDeleted;68 private PlatformUser currentUser;69 private Organization org;70 private List<Session> userSessions;71 @Captor72 private ArgumentCaptor<Object[]> ac;73 @Before74 public void setup() throws Exception {75 MockitoAnnotations.initMocks(this);76 idMgmt = new IdentityServiceBean();77 dm = mock(DataService.class);78 idMgmt.dm = dm;79 sm = mock(SubscriptionServiceLocal.class);80 idMgmt.sm = sm;81 sessionService = mock(SessionServiceLocal.class);82 idMgmt.sessionService = sessionService;83 rvs = mock(ReviewServiceLocalBean.class);84 idMgmt.rvs = rvs;85 principal = mock(Principal.class);86 sessionCtx = mock(SessionContext.class);87 doReturn(principal).when(sessionCtx).getCallerPrincipal();88 idMgmt.sessionCtx = sessionCtx;89 cm = mock(CommunicationServiceLocal.class);90 idMgmt.cm = cm;91 setupUsers();92 doReturn(new ArrayList<Subscription>()).when(sm)93 .getSubscriptionsForUserInt(userToBeDeleted);94 doReturn("Test").when(principal).getName();95 userSessions = new ArrayList<Session>();96 doReturn(userSessions).when(sessionService).getSessionsForUserKey(97 user.getKey());98 }99 @Test(expected = IllegalArgumentException.class)100 public void deleteUser_ArgumentIsNull() throws Exception {101 // given102 user = null;103 // when104 idMgmt.deleteUser(user, null);105 // then106 verify(dm, never()).getReference(PlatformUser.class, anyLong());107 }108 @Test(expected = ObjectNotFoundException.class)109 public void deleteUser_ObjectNotFoundException() throws Exception {110 // given111 doThrow(new ObjectNotFoundException()).when(dm).getReference(112 PlatformUser.class, user.getKey());113 // when114 idMgmt.deleteUser(user, null);115 // then116 verify(dm, times(1))117 .getReference(PlatformUser.class, eq(user.getKey()));118 }119 @Test(expected = ConcurrentModificationException.class)120 public void deleteUser_ConcurrentModificationException() throws Exception {121 // given122 user.setVersion(-1);123 // when124 idMgmt.deleteUser(user, null);125 // then126 verify(dm, times(1))127 .getReference(PlatformUser.class, eq(user.getKey()));128 }129 @Test(expected = OperationNotPermittedException.class)130 public void deleteUser_OperationNotPermittedException() throws Exception {131 // given132 user = createTestUser();133 userToBeDeleted.setOrganization(new Organization());134 currentUser.setOrganization(new Organization());135 // when136 idMgmt.deleteUser(user, null);137 // then138 verify(dm, times(1))139 .getReference(PlatformUser.class, eq(user.getKey()));140 }141 @Test(expected = UserDeletionConstraintException.class)142 public void deleteUser_UserDeletionConstraintException_ActiveSubscription()143 throws Exception {144 // given145 Subscription subscription = new Subscription();146 subscription.setStatus(SubscriptionStatus.ACTIVE);147 doReturn(Arrays.asList(subscription)).when(sm)148 .getSubscriptionsForUserInt(userToBeDeleted);149 // when150 try {151 idMgmt.deleteUser(user, null);152 } catch (UserDeletionConstraintException e) {153 // then154 assertEquals(155 Boolean.TRUE,156 Boolean.valueOf(e157 .getMessageKey()158 .contains(159 String.valueOf(UserDeletionConstraintException.Reason.HAS_ACTIVE_SUBSCRIPTIONS))));160 throw e;161 }162 }163 @Test(expected = UserDeletionConstraintException.class)164 public void deleteUser_UserDeletionConstraintException_IsUserLoggedIn()165 throws Exception {166 // given167 userSessions.add(new Session());168 // when169 try {170 idMgmt.deleteUser(user, null);171 } catch (UserDeletionConstraintException e) {172 // then173 assertEquals(174 Boolean.TRUE,175 Boolean.valueOf(e176 .getMessageKey()177 .contains(178 String.valueOf(UserDeletionConstraintException.Reason.IS_USER_LOGGED_IN))));179 throw e;180 }181 }182 @Test(expected = UserDeletionConstraintException.class)183 public void deleteUser_UserDeletionConstraintException_SelfDelete()184 throws Exception {185 // given186 doReturn(String.valueOf(user.getKey())).when(principal).getName();187 // when188 try {189 idMgmt.deleteUser(user, null);190 } catch (UserDeletionConstraintException e) {191 // then192 assertEquals(193 Boolean.TRUE,194 Boolean.valueOf(e195 .getMessageKey()196 .contains(197 String.valueOf(UserDeletionConstraintException.Reason.FORBIDDEN_SELF_DELETION))));198 throw e;199 }200 }201 @Test202 public void deleteUser_OK() throws Exception {203 // given204 doNothing().when(rvs).deleteReviewsOfUser(userToBeDeleted, false);205 doNothing().when(cm).sendMail(userToBeDeleted, EmailType.USER_DELETED,206 new Object[] { org.getName() }, null);207 // when208 idMgmt.deleteUser(user, null);209 // then210 verify(dm, times(1)).remove(eq(userToBeDeleted));211 verify(cm, times(1)).sendMail(eq(userToBeDeleted),212 eq(EmailType.USER_DELETED), ac.capture(),213 any(Marketplace.class));214 assertEquals(ORGANIZATION_NAME, ac.getValue()[0].toString());215 }216 @Test217 public void deletePlatformUser() throws Exception {218 // given219 Subscription subscription = new Subscription();220 subscription.setStatus(SubscriptionStatus.EXPIRED);221 doReturn(Arrays.asList(subscription)).when(sm)222 .getSubscriptionsForUserInt(userToBeDeleted);223 // when224 idMgmt.deletePlatformUser(userToBeDeleted, false, false,225 new Marketplace());226 // then227 verify(idMgmt.sm, times(1)).revokeUserFromSubscriptionInt(subscription,228 Arrays.asList(userToBeDeleted));229 }230 /**231 * create user for test232 * 233 * @return234 */235 private VOUserDetails createTestUser() {236 VOUserDetails user = new VOUserDetails();237 user.setOrganizationId(ORGANIZATION_ID);238 user.setUserId(ORGANIZATION_ID + "usera");239 user.setEMail("someMail@somehost.com");240 user.setFirstName("Harald");241 user.setLastName("Wilhelm");242 user.setLocale(Locale.ENGLISH.toString());243 return user;244 }245 /**246 * create users and organization for test247 * 248 * @throws Exception249 */250 private void setupUsers() throws Exception {251 user = createTestUser();252 userToBeDeleted = new PlatformUser();253 doReturn(userToBeDeleted).when(dm).getReference(PlatformUser.class,254 user.getKey());255 currentUser = new PlatformUser();256 doReturn(currentUser).when(dm).getCurrentUser();257 org = new Organization();258 org.setName(ORGANIZATION_NAME);259 userToBeDeleted.setOrganization(org);260 currentUser.setOrganization(org);261 }262}...

Full Screen

Full Screen

Source:ConfigurationServiceImplTest.java Github

copy

Full Screen

...28import org.testng.annotations.ObjectFactory;29import org.testng.annotations.Test;30import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;31import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException;32import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;33import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService;34import org.wso2.carbon.device.mgt.jaxrs.service.api.ConfigurationManagementService;35import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;36import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil;37import javax.ws.rs.core.Response;38import java.util.ArrayList;39import java.util.List;40/**41 * This is a test class for {@link ConfigurationServiceImpl}.42 */43@PowerMockIgnore("javax.ws.rs.*")44@SuppressStaticInitializationFor({"org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils",45 "org.wso2.carbon.context.CarbonContext"})46@PrepareForTest({DeviceMgtAPIUtils.class, PolicyManagerUtil.class})47public class ConfigurationServiceImplTest {48 private ConfigurationManagementService configurationManagementService;49 private PlatformConfigurationManagementService platformConfigurationManagementService;50 private PlatformConfiguration platformConfiguration;51 @ObjectFactory52 public IObjectFactory getObjectFactory() {53 return new org.powermock.modules.testng.PowerMockObjectFactory();54 }55 @BeforeClass56 public void init() {57 configurationManagementService = new ConfigurationServiceImpl();58 platformConfigurationManagementService = Mockito.mock(PlatformConfigurationManagementService.class);59 platformConfiguration = new PlatformConfiguration();60 platformConfiguration.setType("test");61 }62 @Test(description = "This method tests the getConfiguration method of ConfigurationManagementService under valid "63 + "conditions")64 public void testGetConfigurationWithSuccessConditions() throws ConfigurationManagementException {65 PowerMockito.stub(PowerMockito.method(PolicyManagerUtil.class, "getMonitoringFrequency")).toReturn(60);66 PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getPlatformConfigurationManagementService"))67 .toReturn(platformConfigurationManagementService);68 Mockito.doReturn(platformConfiguration).when(platformConfigurationManagementService)69 .getConfiguration(Mockito.any());70 Response response = configurationManagementService.getConfiguration("test");71 Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(),72 "getConfiguration request " + "failed with valid parameters");73 List<ConfigurationEntry> configurationEntryList = new ArrayList<>();74 ConfigurationEntry configurationEntry = new ConfigurationEntry();75 configurationEntry.setContentType("String");76 configurationEntry.setName("test");77 configurationEntry.setValue("test");78 configurationEntryList.add(configurationEntry);79 platformConfiguration.setConfiguration(configurationEntryList);80 Mockito.reset(platformConfigurationManagementService);81 Mockito.doReturn(platformConfiguration).when(platformConfigurationManagementService)82 .getConfiguration(Mockito.any());83 response = configurationManagementService.getConfiguration("test");84 Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(),85 "getConfiguration request " + "failed with valid parameters");86 }87 @Test(description = "This method tests the getConfiguration method under negative conditions")88 public void testGetConfigurationUnderNegativeConditions() throws ConfigurationManagementException {89 PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getPlatformConfigurationManagementService"))90 .toReturn(platformConfigurationManagementService);91 Mockito.reset(platformConfigurationManagementService);92 Mockito.doThrow(new ConfigurationManagementException()).when(platformConfigurationManagementService)93 .getConfiguration(Mockito.any());94 Response response = configurationManagementService.getConfiguration("test");95 Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),96 "getConfiguration request " + "succeeded under negative conditions");97 }98 @Test(description = "This method tests the updateConfiguration method under valid conditions.", dependsOnMethods99 = {"testGetConfigurationWithSuccessConditions"})100 public void testUpdateConfigurationUnderValidConditions() throws ConfigurationManagementException {101 Mockito.reset(platformConfigurationManagementService);102 PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getPlatformConfigurationManagementService"))103 .toReturn(platformConfigurationManagementService);104 PowerMockito105 .stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getNotifierFrequency", PlatformConfiguration.class))106 .toReturn(60);107 PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "scheduleTaskService", int.class))108 .toReturn(null);109 Mockito.doReturn(platformConfiguration).when(platformConfigurationManagementService)110 .getConfiguration(Mockito.any());111 Mockito.doReturn(true).when(platformConfigurationManagementService)112 .saveConfiguration(Mockito.any(), Mockito.any());113 Response response = configurationManagementService.updateConfiguration(platformConfiguration);114 Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(),115 "updateConfiguration request failed with valid parameters");116 }117 @Test(description = "This method tests the updateConfiguration method under negative conditions.",118 dependsOnMethods = {"testGetConfigurationWithSuccessConditions"})119 public void testUpdateConfigurationUnderNegativeConditions() throws ConfigurationManagementException {120 Mockito.reset(platformConfigurationManagementService);121 PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getPlatformConfigurationManagementService"))122 .toReturn(platformConfigurationManagementService);123 Mockito.doThrow(new ConfigurationManagementException()).when(platformConfigurationManagementService)124 .saveConfiguration(Mockito.any(), Mockito.any());125 Response response = configurationManagementService.updateConfiguration(platformConfiguration);126 Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),127 "updateConfiguration request succeeded with in-valid parameters");128 }129}...

Full Screen

Full Screen

Source:DefaultAsnServiceTest.java Github

copy

Full Screen

1/*2 * [y] hybris Platform3 *4 * Copyright (c) 2018 SAP SE or an SAP affiliate company.5 * All rights reserved.6 *7 * This software is the confidential and proprietary information of SAP8 * ("Confidential Information"). You shall not disclose such Confidential9 * Information and shall use it only in accordance with the terms of the10 * license agreement you entered into with SAP.11 *12 */13package de.hybris.platform.warehousing.asn.service.impl;14import de.hybris.bootstrap.annotations.UnitTest;15import de.hybris.platform.basecommerce.enums.InStockStatus;16import de.hybris.platform.ordersplitting.model.StockLevelModel;...

Full Screen

Full Screen

Source:LocalizedDataServiceBeanTest.java Github

copy

Full Screen

...79 // given80 Map<String, Properties> map = new HashMap<String, Properties>();81 doReturn(map).when(operatorService).loadMessageProperties(eq("de"));82 doReturn(map).when(operatorService).loadMailProperties(eq("de"));83 doReturn(map).when(operatorService).loadPlatformObjects(eq("de"));84 // when85 List<POLocalizedData> result = bean.exportProperties("de");86 // then87 assertEquals(3, result.size());88 assertEquals(LocalizedDataType.MessageProperties, result.get(0)89 .getType());90 assertEquals(LocalizedDataType.MailProperties, result.get(1).getType());91 assertEquals(LocalizedDataType.PlatformObjects, result.get(2).getType());92 }93 @Test(expected = IllegalArgumentException.class)94 public void loadMessageProperties_NullArgument() throws Exception {95 bean.loadMessageProperties(null);96 }97 @Test98 public void loadMessageProperties_OK() throws Exception {99 // given100 Properties prop = new Properties();101 doReturn(prop).when(operatorService).loadPropertiesFromDB(eq("de"));102 // when103 Properties result = bean.loadMessageProperties("de");104 // then105 verify(operatorService, times(1)).loadPropertiesFromDB(eq("de"));106 assertEquals(prop, result);107 }108 @Test109 public void loadMailPropertiesFromFile_OK() throws Exception {110 // given111 Properties props = new Properties();112 doReturn(props).when(localizer).loadLocalizedPropertiesFromFile(113 anyString(), eq("de"));114 // when115 Properties result = bean.loadMailPropertiesFromFile("de");116 // then117 verify(localizer, times(1)).loadLocalizedPropertiesFromFile(118 anyString(), eq("de"));119 assertEquals(props, result);120 }121 @Test(expected = IllegalArgumentException.class)122 public void loadMailPropertiesFromFile_null() throws Exception {123 // when124 try {125 bean.loadMailPropertiesFromFile(null);126 fail();127 } catch (IllegalArgumentException e) {128 // then129 verify(localizer, never()).loadLocalizedPropertiesFromFile(anyString(), anyString());130 throw e;131 }132 }133 @Test134 public void loadPlatformObjectPropertiesFromFile_OK() throws Exception {135 // given136 Properties props = new Properties();137 doReturn(props).when(operatorService).loadPlatformObjectsFromFile(138 eq("de"));139 // when140 Properties result = bean.loadPlatformObjectsFromFile("de");141 // then142 verify(operatorService, times(1)).loadPlatformObjectsFromFile(eq("de"));143 assertEquals(props, result);144 }145 @Test(expected = IllegalArgumentException.class)146 public void loadPlatformObjectPropertiesFromFile_null() throws Exception {147 // when148 try {149 bean.loadPlatformObjectsFromFile(null);150 fail();151 } catch (IllegalArgumentException e) {152 // then153 verify(operatorService, never()).loadPropertiesFromDB(anyString());154 throw e;155 }156 }157 @Test158 public void toPOLocalizedData_NullArgument() {159 assertNotNull(bean.toPOLocalizedData(null, null));160 }161 @Test162 public void toPOLocalizedData() {163 // given...

Full Screen

Full Screen

Source:OperationRecordServiceBeanTest.java Github

copy

Full Screen

...19import java.util.Locale;20import org.junit.Before;21import org.junit.Test;22import org.oscm.dataservice.local.DataService;23import org.oscm.domobjects.PlatformUser;24import org.oscm.domobjects.Subscription;25import org.oscm.techproductoperation.bean.OperationRecordServiceLocalBean;26import org.oscm.internal.types.exception.IllegalArgumentException;27import org.oscm.internal.types.exception.ObjectNotFoundException;28/**29 * @author maoq30 * 31 */32public class OperationRecordServiceBeanTest {33 private OperationRecordServiceBean operationRecordService;34 private OperationRecordServiceLocalBean operationRecordServiceLocal;35 private DataService dataService;36 @Before37 public void setup() {38 operationRecordService = spy(new OperationRecordServiceBean());39 operationRecordServiceLocal = mock(OperationRecordServiceLocalBean.class);40 dataService = mock(DataService.class);41 operationRecordService.operationRecordServiceLocalBean = operationRecordServiceLocal;42 operationRecordService.dm = dataService;43 }44 @Test45 public void getOperationRecords_myOperationsOnly() throws Exception {46 // when47 operationRecordService.getOperationRecords(Boolean.TRUE,48 Locale.ENGLISH.getLanguage());49 // then50 verify(operationRecordServiceLocal, times(1)).getOperationRecords(51 eq(true));52 }53 @Test54 public void getOperationRecords() throws Exception {55 // when56 operationRecordService.getOperationRecords(Boolean.FALSE,57 Locale.ENGLISH.getLanguage());58 // then59 verify(operationRecordServiceLocal, times(1)).getOperationRecords(60 eq(false));61 }62 @Test(expected = IllegalArgumentException.class)63 public void deleteOperationRecords_IllegalArgumentException()64 throws Exception {65 // given66 Subscription sub = new Subscription();67 sub.setKey(1000L);68 PlatformUser user = new PlatformUser();69 user.setKey(1001L);70 when(71 operationRecordService.dm.getReference(Subscription.class,72 sub.getKey())).thenReturn(sub);73 when(74 operationRecordService.dm.getReference(PlatformUser.class,75 user.getKey())).thenReturn(user);76 // when77 operationRecordService.deleteOperationRecords(null);78 }79 @Test(expected = ObjectNotFoundException.class)80 public void deleteOperationRecords() throws Exception {81 // given82 doThrow(new ObjectNotFoundException())83 .when(operationRecordServiceLocal).deleteOperationRecords(84 anyListOf(Long.class));85 List<POOperationRecord> operationRecords = new ArrayList<POOperationRecord>();86 POSubscription poSubscription = new POSubscription();87 poSubscription.setKey(1000L);88 Subscription sub = new Subscription();89 sub.setKey(1000L);90 POUser poUser = new POUser();91 poUser.setKey(1001L);92 PlatformUser user = new PlatformUser();93 user.setKey(1001L);94 POOperationRecord record = new POOperationRecord();95 record.setKey(1002L);96 record.setSubscription(poSubscription);97 record.setUser(poUser);98 operationRecords.add(record);99 when(100 operationRecordService.dm.getReference(Subscription.class,101 record.getSubscription().getKey())).thenReturn(sub);102 when(103 operationRecordService.dm.getReference(PlatformUser.class,104 record.getUser().getKey())).thenReturn(user);105 // when106 operationRecordService.deleteOperationRecords(operationRecords);107 // then108 verify(operationRecordServiceLocal, times(1)).deleteOperationRecords(109 anyListOf(Long.class));110 }111}...

Full Screen

Full Screen

Source:AccountServiceBeanEditProfileTest.java Github

copy

Full Screen

...21import org.oscm.communicationservice.local.CommunicationServiceLocal;22import org.oscm.dataservice.local.DataService;23import org.oscm.domobjects.Marketplace;24import org.oscm.domobjects.Organization;25import org.oscm.domobjects.PlatformUser;26import org.oscm.domobjects.RoleAssignment;27import org.oscm.domobjects.UserRole;28import org.oscm.identityservice.local.IdentityServiceLocal;29import org.oscm.types.enumtypes.EmailType;30import org.oscm.internal.types.enumtypes.UserRoleType;31import org.oscm.internal.types.exception.OperationNotPermittedException;32import org.oscm.internal.vo.VOUserDetails;33/**34 * @author zhaohang35 * 36 */37public class AccountServiceBeanEditProfileTest {38 private AccountServiceBean asb;39 private final PlatformUser user = new PlatformUser();40 String marketplaceId = "marketplaceId";41 Marketplace marketplace = new Marketplace();42 List<PlatformUser> platformUsers = new LinkedList<PlatformUser>();43 @Before44 public void setup() throws Exception {45 asb = new AccountServiceBean();46 asb.dm = mock(DataService.class);47 asb.cs = mock(CommunicationServiceLocal.class);48 asb.im = mock(IdentityServiceLocal.class);49 Organization org = new Organization();50 user.setOrganization(org);51 user.setEmail(null);52 platformUsers.add(user);53 doReturn(marketplace).when(asb.dm).getReferenceByBusinessKey(54 any(Marketplace.class));55 doReturn(user).when(asb.dm).getCurrentUser();56 doReturn(new SendMailStatus<PlatformUser>()).when(asb.cs).sendMail(57 any(EmailType.class), any(Object[].class),58 any(Marketplace.class), any(PlatformUser[].class));59 }60 @Test61 public void updateAccountInformation_OrganizationAdmin() throws Exception {62 // given63 VOUserDetails voUser = new VOUserDetails();64 Organization org = new Organization();65 doReturn(null).when(asb.im).modifyUserData(user, voUser, true, false);66 setAdminRole(UserRoleType.ORGANIZATION_ADMIN);67 // when68 asb.updateAccountInformation(org, voUser, marketplaceId);69 // then70 verify(asb.cs, times(1)).sendMail(EmailType.ORGANIZATION_UPDATED, null,71 marketplace,72 platformUsers.toArray(new PlatformUser[platformUsers.size()]));73 }74 @Test75 public void updateAccountInformation_NotOrganizationAdmin()76 throws Exception {77 // given78 VOUserDetails voUser = new VOUserDetails();79 doReturn(null).when(asb.im).modifyUserData(user, voUser, true, false);80 setAdminRole(UserRoleType.ORGANIZATION_ADMIN);81 // when82 asb.updateAccountInformation(null, voUser, marketplaceId);83 // then84 verify(asb.cs, times(1)).sendMail(EmailType.ORGANIZATION_UPDATED, null,85 marketplace,86 platformUsers.toArray(new PlatformUser[platformUsers.size()]));87 }88 @Test(expected = OperationNotPermittedException.class)89 public void updateAccountInformation_OperationNotPermitted()90 throws Exception {91 // given92 VOUserDetails voUser = new VOUserDetails();93 Organization org = new Organization();94 doReturn(null).when(asb.im).modifyUserData(user, voUser, true, false);95 setAdminRole(UserRoleType.SUBSCRIPTION_MANAGER);96 // when97 asb.updateAccountInformation(org, voUser, marketplaceId);98 }99 private void setAdminRole(UserRoleType type) {100 Set<RoleAssignment> grantedRoles = new HashSet<RoleAssignment>();...

Full Screen

Full Screen

Source:PlatformSettingCtrlTest.java Github

copy

Full Screen

...26import org.mockito.MockitoAnnotations;27import org.oscm.ui.beans.BaseBean;28import org.oscm.ui.dialog.common.ldapsettings.LdapSetting;29import org.oscm.ui.dialog.common.ldapsettings.LdapSettingConverter;30import org.oscm.ui.dialog.common.ldapsettings.PlatformSettingCtrl;31import org.oscm.ui.dialog.common.ldapsettings.PlatformSettingModel;32import org.oscm.internal.usermanagement.POLdapSetting;33import org.oscm.internal.usermanagement.UserManagementService;34public class PlatformSettingCtrlTest {35 private PlatformSettingCtrl ctrl;36 private LdapSettingConverter converter;37 private UserManagementService ums;38 private PlatformSettingModel model;39 private Set<POLdapSetting> serverSettings = new HashSet<POLdapSetting>();40 @Captor41 ArgumentCaptor<byte[]> writtenContent;42 @Before43 public void setup() throws IOException {44 MockitoAnnotations.initMocks(this);45 ctrl = spy(new PlatformSettingCtrl());46 converter = spy(new LdapSettingConverter());47 ums = mock(UserManagementService.class);48 model = new PlatformSettingModel();49 ctrl.setModel(model);50 doReturn(converter).when(ctrl).getSettingConverter();51 doReturn(ums).when(ctrl).getUserManagementService();52 doReturn(serverSettings).when(ums).getPlatformSettings();53 doNothing().when(ctrl).writeSettings(writtenContent.capture());54 }55 @Test56 public void initModelData_Delegation() {57 ctrl.initModelData();58 verify(ums, times(1)).getPlatformSettings();59 verifyNoMoreInteractions(ums);60 verify(converter, times(1)).addToModel(61 same(model.getPlatformSettings()), same(serverSettings));62 }63 @Test64 public void exportSettings_Delegation() throws IOException {65 String result = ctrl.exportSettings();66 verify(converter, times(1)).toProperties(67 same(model.getPlatformSettings()), eq(false));68 assertEquals(BaseBean.OUTCOME_SUCCESS, result);69 }70 @Test71 public void exportSettings_ContentValidation() throws IOException {72 model.getPlatformSettings().add(new LdapSetting("key", "value", false));73 ctrl.exportSettings();74 ByteArrayInputStream bais = new ByteArrayInputStream(75 writtenContent.getValue());76 Properties props = new Properties();77 props.load(bais);78 assertEquals(1, props.keySet().size());79 assertEquals("value", props.getProperty("key"));80 }81 @Test82 public void isPlatformSettingsDefined_ContentValidation_Empty() {83 assertFalse(ctrl.isPlatformSettingsDefined());84 }85 @Test86 public void isPlatformSettingsDefined_ContentValidation_SettingsDefined() {87 model.getPlatformSettings().add(new LdapSetting("key", "value", false));88 assertTrue(ctrl.isPlatformSettingsDefined());89 }90}...

Full Screen

Full Screen

Source:AndroidByteBuddyMockMaker.java Github

copy

Full Screen

...4 */5package org.mockito.android.internal.creation;6import org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker;7import org.mockito.internal.util.ConsoleMockitoLogger;8import org.mockito.internal.util.Platform;9import org.mockito.invocation.MockHandler;10import org.mockito.mock.MockCreationSettings;11import org.mockito.plugins.MockMaker;12import static org.mockito.internal.util.StringUtil.join;13public class AndroidByteBuddyMockMaker implements MockMaker {14 private final MockMaker delegate;15 public AndroidByteBuddyMockMaker() {16 if (Platform.isAndroid() || Platform.isAndroidMockMakerRequired()) {17 delegate = new SubclassByteBuddyMockMaker(new AndroidLoadingStrategy());18 } else {19 new ConsoleMockitoLogger().log(join(20 "IMPORTANT NOTE FROM MOCKITO:",21 "",22 "You included the 'mockito-android' dependency in a non-Android environment.",23 "The Android mock maker was disabled. You should only include the latter in your 'androidTestCompile' configuration",24 "If disabling was a mistake, you can set the 'org.mockito.mock.android' property to 'true' to override this detection.",25 "",26 "Visit https://javadoc.io/page/org.mockito/mockito-core/latest/org/mockito/Mockito.html#0.1 for more information"27 ));28 delegate = new SubclassByteBuddyMockMaker();29 }30 }...

Full Screen

Full Screen

Platform

Using AI Code Generation

copy

Full Screen

1import org.mockito.internal.util.Platform;2public class MockitoTest {3 public static void main(String[] args) {4 System.out.println(Platform.isAndroid());5 }6}

Full Screen

Full Screen

Platform

Using AI Code Generation

copy

Full Screen

1import org.mockito.internal.util.*;2import org.mockito.*;3import org.mockito.exceptions.*;4import org.mockito.internal.*;5import org.mockito.internal.invocation.*;6import org.mockito.internal.matchers.*;7import org.mockito.internal.progress.*;8import org.mockito.internal.stubbing.*;9import org.mockito.internal.verification.*;10import org.mockito.internal.verification.api.*;11import org.mockito.invocation.*;12import org.mockito.listeners.*;13import org.mockito.matchers.*;14import org.mockito.stubbing.*;15import org.mockito.verification.*;16public class 1 {17 public static void main(String args[]) {18 System.out.println(Platform.isAndroid());19 }20}21import org.mockito.internal.util.*;22import org.mockito.*;23import org.mockito.exceptions.*;24import org.mockito.internal.*;25import org.mockito.internal.invocation.*;26import org.mockito.internal.matchers.*;27import org.mockito.internal.progress.*;28import org.mockito.internal.stubbing.*;29import org.mockito.internal.verification.*;30import org.mockito.internal.verification.api.*;31import org.mockito.invocation.*;32import org.mockito.listeners.*;33import org.mockito.matchers.*;34import org.mockito.stubbing.*;35import org.mockito.verification.*;36public class 2 {37 public static void main(String args[]) {38 System.out.println(Platform.isAndroid());39 }40}41import org.mockito.internal.util.*;42import org.mockito.*;43import org.mockito.exceptions.*;44import org.mockito.internal.*;45import org.mockito.internal.invocation.*;46import org.mockito.internal.matchers.*;47import org.mockito.internal.progress.*;48import org.mockito.internal.stubbing.*;49import org.mockito.internal.verification.*;50import org.mockito.internal.verification.api.*;51import org.mockito.invocation.*;52import org.mockito.listeners.*;53import org.mockito.matchers.*;54import org.mockito.stubbing.*;55import org.mockito.verification.*;56public class 3 {57 public static void main(String args[]) {58 System.out.println(Platform.isAndroid());59 }60}61import org.mockito.internal.util.*;62import org.mockito.*;63import org.mockito.exceptions.*;64import org.mockito.internal.*;65import org.mockito.internal.invocation.*;66import org.mockito.internal.matchers.*;67import org.mockito.internal.progress.*;68import org.mockito.internal.stubbing.*;69import org.mockito.internal.verification.*;70import org.mockito.internal.verification.api.*;71import org.mockito.invocation.*;72import org.mockito.listeners

Full Screen

Full Screen

Platform

Using AI Code Generation

copy

Full Screen

1import org.mockito.internal.util.Platform;2{3 public static void main(String args[])4 {5 System.out.println("Platform.isAndroid(): " + Platform.isAndroid());6 }7}8Platform.isAndroid(): false9Recommended Posts: Mockito - Mockito.mock(Class, Answer)10Mockito - Mockito.mock(Class, Answer, MockSettings)11Mockito - Mockito.mock(Class, MockSettings)12Mockito - Mockito.mock(Class, Answer, MockName)13Mockito - Mockito.mock(Class, MockName)14Mockito - Mockito.mock(Class, Answer, MockName, MockCreationSettings)15Mockito - Mockito.mock(Class, MockCreationSettings)16Mockito - Mockito.mock(Class, Answer, MockCreationSettings)17Mockito - Mockito.mock(Class, Answer, MockName, MockCreationSettings, Object)18Mockito - Mockito.mock(Class, MockCreationSettings, Object)19Mockito - Mockito.mock(Class, Answer, MockCreationSettings, Object)20Mockito - Mockito.mock(Class, Answer, MockName, MockCreationSettings, Object, Object)21Mockito - Mockito.mock(Class, MockCreationSettings, Object, Object)22Mockito - Mockito.mock(Class, Answer, MockCreationSettings, Object, Object)23Mockito - Mockito.mock(Class, Answer, MockName, MockCreationSettings, Object, Object, Object)24Mockito - Mockito.mock(Class, MockCreationSettings, Object, Object, Object)25Mockito - Mockito.mock(Class, Answer, MockCreationSettings, Object, Object, Object)26Mockito - Mockito.mock(Class, Answer, MockName, MockCreationSettings, Object, Object, Object, Object)27Mockito - Mockito.mock(Class, MockCreationSettings, Object, Object, Object, Object)28Mockito - Mockito.mock(Class, Answer, MockCreationSettings, Object, Object, Object, Object)29Mockito - Mockito.mock(Class, Answer, MockName, MockCreationSettings, Object, Object, Object, Object, Object)30Mockito - Mockito.mock(Class, MockCreationSettings, Object, Object, Object, Object, Object)31Mockito - Mockito.mock(Class, Answer, MockCreationSettings, Object, Object, Object, Object, Object)32Mockito - Mockito.mock(Class, Answer, MockName, MockCreationSettings, Object, Object, Object, Object, Object, Object)

Full Screen

Full Screen

Platform

Using AI Code Generation

copy

Full Screen

1public class PlatformDemo {2 public static void main(String[] args) {3 System.out.println(Platform.getCurrent());4 }5}6public class PlatformDemo {7 public static void main(String[] args) {8 System.out.println(Platform.getCurrent());9 }10}11public class PlatformDemo {12 public static void main(String[] args) {13 System.out.println(Platform.getCurrent());14 }15}16public class PlatformDemo {17 public static void main(String[] args) {18 System.out.println(Platform.getCurrent());19 }20}21public class PlatformDemo {22 public static void main(String[] args) {23 System.out.println(Platform.getCurrent());24 }25}26public class PlatformDemo {27 public static void main(String[] args) {28 System.out.println(Platform.getCurrent());29 }30}31public class PlatformDemo {32 public static void main(String[] args) {

Full Screen

Full Screen

Platform

Using AI Code Generation

copy

Full Screen

1import org.mockito.internal.util.Platform;2public class MockingPlatform {3 public static void main(String args[]) {4 Platform platform = Platform.getCurrent();5 System.out.println(platform);6 }7}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Mockito automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful