use of org.joda.time.LocalDateTime in project joda-time by JodaOrg.
the class TestDateTimeFormatterBuilder method test_localPrintParseOffset.
public void test_localPrintParseOffset() {
DateTimeFormatterBuilder bld = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd HH:mm ").appendTimeZoneOffset("Z", true, 2, 2);
DateTimeFormatter f = bld.toFormatter();
DateTime dt = new DateTime(2007, 3, 4, 12, 30, 0, TOKYO);
assertEquals("2007-03-04 12:30 +09:00", f.print(dt));
LocalDateTime expected = new LocalDateTime(2007, 3, 4, 12, 30);
assertEquals(expected, f.parseLocalDateTime("2007-03-04 12:30 +09:00"));
assertEquals(expected, f.withZone(TOKYO).parseLocalDateTime("2007-03-04 12:30 +09:00"));
assertEquals(expected, f.withOffsetParsed().parseLocalDateTime("2007-03-04 12:30 +09:00"));
}
use of org.joda.time.LocalDateTime in project joda-time by JodaOrg.
the class TestDateTimeFormatterBuilder method test_localParseWrongOffsetAndZone.
public void test_localParseWrongOffsetAndZone() {
DateTimeFormatterBuilder bld = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd HH:mm ").appendTimeZoneOffset("Z", true, 2, 2).appendLiteral(' ').appendTimeZoneId();
DateTimeFormatter f = bld.toFormatter();
LocalDateTime expected = new LocalDateTime(2007, 3, 4, 12, 30);
// parses offset time then adjusts to parsed zone
assertEquals(expected, f.parseLocalDateTime("2007-03-04 12:30 +07:00 Asia/Tokyo"));
// parses offset time then adjusts to requested zone
assertEquals(expected, f.withZone(TOKYO).parseLocalDateTime("2007-03-04 12:30 +07:00 Asia/Tokyo"));
// parses offset time returning offset zone (ignores zone)
assertEquals(expected, f.withOffsetParsed().parseLocalDateTime("2007-03-04 12:30 +07:00 Asia/Tokyo"));
}
use of org.joda.time.LocalDateTime in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest method provisioningD_UpdateAccount_Extended_Attribute.
@Test
public void provisioningD_UpdateAccount_Extended_Attribute() {
IdmRoleFilter filter = new IdmRoleFilter();
filter.setProperty(IdmRole_.name.getName());
filter.setValue(ROLE_NAME_TEN);
IdmRoleDto roleTen = roleService.find(filter, null).getContent().get(0);
Assert.assertNotNull(roleTen);
Assert.assertTrue(formService.getValues(roleTen.getId(), IdmRole.class, "changed").isEmpty());
// Check state before provisioning
TestRoleResource ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
Assert.assertNotNull(ten);
Assert.assertEquals(null, ten.getModified());
// Create extended attribute
LocalDateTime now = LocalDateTime.now();
formService.saveValues(roleTen.getId(), IdmRole.class, "changed", ImmutableList.of(now.toString(DATE_TABLE_CONNECTOR_FORMAT)));
// Save IDM changed node (must invoke provisioning)
roleService.save(roleTen);
// Check state after provisioning
ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
Assert.assertNotNull(ten);
Assert.assertEquals(now.toString(DATE_TABLE_CONNECTOR_FORMAT), ten.getModified().toString(DATE_TABLE_CONNECTOR_FORMAT));
}
use of org.joda.time.LocalDateTime in project CzechIdMng by bcvsolutions.
the class DefaultAccAccountServiceTest method getConnectorObjectNotFullForbiddenTest.
/**
* We do not create relation Identity account ... we must not have the
* permissions on the account
*/
@Test(expected = ForbiddenEntityException.class)
public void getConnectorObjectNotFullForbiddenTest() {
String userOneName = "UserOne";
String eavAttributeName = "EAV_ATTRIBUTE";
SysSystemDto system = initData();
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
// Find and delete EAV schema attribute.
SysSchemaAttributeDto eavAttribute = schemaAttributeService.find(schemaAttributeFilter, null).getContent().stream().filter(attribute -> attribute.getName().equalsIgnoreCase(eavAttributeName)).findFirst().orElse(null);
Assert.assertNotNull(eavAttribute);
schemaAttributeService.delete(eavAttribute);
Assert.assertNotNull(system);
// Change resources (set state on exclude) .. must be call in transaction
this.getBean().persistResource(createResource(userOneName, new LocalDateTime()));
AccAccountDto account = new AccAccountDto();
account.setEntityType(SystemEntityType.IDENTITY);
account.setSystem(system.getId());
account.setAccountType(AccountType.PERSONAL);
account.setUid(userOneName);
account = accountService.save(account);
IdmIdentityDto identity = helper.createIdentity();
// Create role with evaluator
IdmRoleDto role = helper.createRole();
IdmAuthorizationPolicyDto policyAccount = new IdmAuthorizationPolicyDto();
policyAccount.setRole(role.getId());
policyAccount.setGroupPermission(AccGroupPermission.ACCOUNT.getName());
policyAccount.setAuthorizableType(AccAccount.class.getCanonicalName());
policyAccount.setEvaluator(ReadAccountByIdentityEvaluator.class);
authorizationPolicyService.save(policyAccount);
// Assign role with evaluator
helper.createIdentityRole(identity, role);
logout();
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
IcConnectorObject connectorObject = accountService.getConnectorObject(account, IdmBasePermission.READ);
Assert.assertNotNull(connectorObject);
Assert.assertEquals(userOneName, connectorObject.getUidValue());
// EAV attribute must be null, because we deleted the schema definition
Assert.assertNull(connectorObject.getAttributeByName(eavAttributeName));
}
use of org.joda.time.LocalDateTime in project CzechIdMng by bcvsolutions.
the class DefaultAccAccountServiceTest method getConnectorObjectNotFullTest.
@Test
public void getConnectorObjectNotFullTest() {
String userOneName = "UserOne";
String eavAttributeName = "EAV_ATTRIBUTE";
SysSystemDto system = initData();
SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
schemaAttributeFilter.setSystemId(system.getId());
// Find and delete EAV schema attribute.
SysSchemaAttributeDto eavAttribute = schemaAttributeService.find(schemaAttributeFilter, null).getContent().stream().filter(attribute -> attribute.getName().equalsIgnoreCase(eavAttributeName)).findFirst().orElse(null);
Assert.assertNotNull(eavAttribute);
schemaAttributeService.delete(eavAttribute);
Assert.assertNotNull(system);
// Change resources (set state on exclude) .. must be call in transaction
this.getBean().persistResource(createResource(userOneName, new LocalDateTime()));
AccAccountDto account = new AccAccountDto();
account.setEntityType(SystemEntityType.IDENTITY);
account.setSystem(system.getId());
account.setAccountType(AccountType.PERSONAL);
account.setUid(userOneName);
account = accountService.save(account);
IdmIdentityDto identity = helper.createIdentity();
AccIdentityAccountDto accountIdentityOne = new AccIdentityAccountDto();
accountIdentityOne.setIdentity(identity.getId());
accountIdentityOne.setOwnership(true);
accountIdentityOne.setAccount(account.getId());
accountIdentityOne = identityAccountService.save(accountIdentityOne);
// Create role with evaluator
IdmRoleDto role = helper.createRole();
IdmAuthorizationPolicyDto policyAccount = new IdmAuthorizationPolicyDto();
policyAccount.setRole(role.getId());
policyAccount.setGroupPermission(AccGroupPermission.ACCOUNT.getName());
policyAccount.setAuthorizableType(AccAccount.class.getCanonicalName());
policyAccount.setEvaluator(ReadAccountByIdentityEvaluator.class);
authorizationPolicyService.save(policyAccount);
// Assign role with evaluator
helper.createIdentityRole(identity, role);
logout();
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
IcConnectorObject connectorObject = accountService.getConnectorObject(account, IdmBasePermission.READ);
Assert.assertNotNull(connectorObject);
Assert.assertEquals(userOneName, connectorObject.getUidValue());
// EAV attribute must be null, because we deleted the schema definition
Assert.assertNull(connectorObject.getAttributeByName(eavAttributeName));
}
Aggregations