mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Add preset variable account created (#10200)
This commit is contained in:
parent
3b108b968f
commit
398ffc3b2c
@ -17,11 +17,19 @@
|
|||||||
|
|
||||||
package org.apache.cloudstack.quota.activationrule.presetvariables;
|
package org.apache.cloudstack.quota.activationrule.presetvariables;
|
||||||
|
|
||||||
|
import com.cloud.utils.DateUtil;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
public class Account extends GenericPresetVariable {
|
public class Account extends GenericPresetVariable {
|
||||||
@PresetVariableDefinition(description = "Role of the account. This field will not exist if the account is a project.")
|
@PresetVariableDefinition(description = "Role of the account. This field will not exist if the account is a project.")
|
||||||
|
|
||||||
private Role role;
|
private Role role;
|
||||||
|
|
||||||
|
@PresetVariableDefinition(description = "The date the account was created in GMT. This field will not exist for the first root admin account.")
|
||||||
|
private String created;
|
||||||
|
|
||||||
public Role getRole() {
|
public Role getRole() {
|
||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
@ -31,4 +39,12 @@ public class Account extends GenericPresetVariable {
|
|||||||
fieldNamesToIncludeInToString.add("role");
|
fieldNamesToIncludeInToString.add("role");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCreated() {
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreated(Date created) {
|
||||||
|
this.created = DateUtil.displayDateInTimezone(TimeZone.getTimeZone("GMT"), created);
|
||||||
|
fieldNamesToIncludeInToString.add("created");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -224,6 +224,7 @@ public class PresetVariableHelper {
|
|||||||
Account account = new Account();
|
Account account = new Account();
|
||||||
account.setId(accountVo.getUuid());
|
account.setId(accountVo.getUuid());
|
||||||
account.setName(accountVo.getName());
|
account.setName(accountVo.getName());
|
||||||
|
account.setCreated(accountVo.getCreated());
|
||||||
|
|
||||||
setPresetVariableRoleInAccountIfAccountIsNotAProject(accountVo.getType(), accountVo.getRoleId(), account);
|
setPresetVariableRoleInAccountIfAccountIsNotAProject(accountVo.getType(), accountVo.getRoleId(), account);
|
||||||
|
|
||||||
|
|||||||
@ -375,11 +375,12 @@ public class PresetVariableHelperTest {
|
|||||||
Account account = getAccountForTests();
|
Account account = getAccountForTests();
|
||||||
Mockito.doReturn(account.getId()).when(accountVoMock).getUuid();
|
Mockito.doReturn(account.getId()).when(accountVoMock).getUuid();
|
||||||
Mockito.doReturn(account.getName()).when(accountVoMock).getName();
|
Mockito.doReturn(account.getName()).when(accountVoMock).getName();
|
||||||
|
Mockito.doReturn(account.getCreated()).when(accountVoMock).getCreated();
|
||||||
|
|
||||||
Account result = presetVariableHelperSpy.getPresetVariableAccount(1l);
|
Account result = presetVariableHelperSpy.getPresetVariableAccount(1l);
|
||||||
|
|
||||||
assertPresetVariableIdAndName(account, result);
|
assertPresetVariableIdAndName(account, result);
|
||||||
validateFieldNamesToIncludeInToString(Arrays.asList("id", "name"), result);
|
validateFieldNamesToIncludeInToString(Arrays.asList("created", "id", "name"), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user