use of org.openstack4j.model.identity.v3.User in project camel by apache.
the class UserProducerTest method setUp.
@Before
public void setUp() {
producer = new UserProducer(endpoint, client);
when(userService.create(any(User.class))).thenReturn(testOSuser);
when(userService.get(anyString())).thenReturn(testOSuser);
List<User> getAllList = new ArrayList<>();
getAllList.add(testOSuser);
getAllList.add(testOSuser);
doReturn(getAllList).when(userService).list();
dummyUser = createUser();
when(testOSuser.getName()).thenReturn(dummyUser.getName());
when(testOSuser.getDescription()).thenReturn(dummyUser.getDescription());
when(testOSuser.getPassword()).thenReturn(dummyUser.getPassword());
when(testOSuser.getDomainId()).thenReturn(dummyUser.getDomainId());
when(testOSuser.getEmail()).thenReturn(dummyUser.getEmail());
}
use of org.openstack4j.model.identity.v3.User in project camel by apache.
the class UserProducerTest method updateTest.
@Test
public void updateTest() throws Exception {
final String id = "myID";
msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.UPDATE);
when(testOSuser.getId()).thenReturn(id);
final String newDescription = "ndesc";
when(testOSuser.getDescription()).thenReturn(newDescription);
when(userService.update(any(User.class))).thenReturn(testOSuser);
msg.setBody(testOSuser);
producer.process(exchange);
ArgumentCaptor<User> captor = ArgumentCaptor.forClass(User.class);
verify(userService).update(captor.capture());
assertEqualsUser(testOSuser, captor.getValue());
assertNotNull(captor.getValue().getId());
assertEquals(newDescription, msg.getBody(User.class).getDescription());
}
use of org.openstack4j.model.identity.v3.User in project camel by apache.
the class UserProducer method doUpdate.
private void doUpdate(Exchange exchange) {
final Message msg = exchange.getIn();
final User in = messageToUser(msg);
final User out = osV3Client.identity().users().update(in);
msg.setBody(out);
}
use of org.openstack4j.model.identity.v3.User in project Douya by DreaminginCodeZH.
the class NavigationAccountListLayout method bind.
public void bind() {
List<Account> accountList = new ArrayList<>(Arrays.asList(AccountUtils.getAccounts()));
accountList.remove(AccountUtils.getActiveAccount());
Account recentOneAccount = AccountUtils.getRecentOneAccount();
if (recentOneAccount != null) {
accountList.remove(recentOneAccount);
}
Account recentTwoAccount = AccountUtils.getRecentTwoAccount();
if (recentTwoAccount != null) {
accountList.remove(recentTwoAccount);
}
if (recentOneAccount != null) {
accountList.add(recentOneAccount);
}
if (recentTwoAccount != null) {
accountList.add(recentTwoAccount);
}
int i = 0;
for (final Account account : accountList) {
if (i >= mAccountList.getChildCount()) {
ViewUtils.inflateInto(R.layout.navigation_account_item, mAccountList);
}
View accountLayout = mAccountList.getChildAt(i);
accountLayout.setVisibility(VISIBLE);
AccountLayoutHolder holder = (AccountLayoutHolder) accountLayout.getTag();
if (holder == null) {
holder = new AccountLayoutHolder(accountLayout);
accountLayout.setTag(holder);
}
User user = mAdapter.getUser(account);
if (user != null) {
ImageUtils.loadNavigationAccountListAvatar(holder.avatarImage, user.getLargeAvatarOrAvatar());
} else {
holder.avatarImage.setImageResource(R.drawable.avatar_icon_grey600_40dp);
}
holder.nameText.setText(mAdapter.getPartialUser(account).name);
accountLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (mListener != null) {
mListener.switchToAccount(account);
}
}
});
++i;
}
ViewUtils.setVisibleOrGone(mDividerView, i > 0);
for (int count = mAccountList.getChildCount(); i < count; ++i) {
mAccountList.getChildAt(i).setVisibility(GONE);
}
}
use of org.openstack4j.model.identity.v3.User in project Douya by DreaminginCodeZH.
the class ProfileActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(0, 0);
// Calls ensureSubDecor().
findViewById(android.R.id.content);
if (savedInstanceState == null) {
Intent intent = getIntent();
String userIdOrUid = intent.getStringExtra(EXTRA_USER_ID_OR_UID);
SimpleUser simpleUser = intent.getParcelableExtra(EXTRA_SIMPLE_USER);
User user = intent.getParcelableExtra(EXTRA_USER_INFO);
mProfileFragment = ProfileFragment.newInstance(userIdOrUid, simpleUser, user);
FragmentUtils.add(mProfileFragment, this, android.R.id.content);
} else {
mProfileFragment = FragmentUtils.findById(this, android.R.id.content);
}
}
Aggregations