@Test public final void testReadCreateRestAttributes() { final OracleAttributesReader reader = new OracleAttributesReader(TestHelpers.createDummyMessages()); OracleUserAttributes.Builder caAttributes = new OracleUserAttributes.Builder(); caAttributes.setUserName("testUser"); Set<Attribute> attributes = new HashSet<Attribute>(); attributes.add(AttributeBuilder.buildPasswordExpired(true)); attributes.add(AttributeBuilder.build(OracleConstants.ORACLE_DEF_TS_ATTR_NAME, "defts")); attributes.add(AttributeBuilder.build(OracleConstants.ORACLE_TEMP_TS_ATTR_NAME, "tempts")); attributes.add(AttributeBuilder .build(OracleConstants.ORACLE_PROFILE_ATTR_NAME, "myprofile")); attributes.add(AttributeBuilder.buildEnabled(true)); attributes .add(AttributeBuilder.build(OracleConstants.ORACLE_DEF_TS_QUOTA_ATTR_NAME, "30M")); attributes.add(AttributeBuilder.build(OracleConstants.ORACLE_TEMP_TS_QUOTA_ATTR_NAME, "100M")); reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.assertEquals("defts", caAttributes.getDefaultTableSpace()); Assert.assertTrue(caAttributes.getExpirePassword()); Assert.assertEquals("tempts", caAttributes.getTempTableSpace()); Assert.assertEquals("myprofile", caAttributes.getProfile()); Assert.assertTrue(caAttributes.getEnable()); Assert.assertEquals("30M", caAttributes.getDefaultTSQuota()); Assert.assertEquals("100M", caAttributes.getTempTSQuota()); attributes.clear(); reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); attributes.add(AttributeBuilder.build(OperationalAttributes.PASSWORD_EXPIRED_NAME, "invalid")); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.fail("Must fail for invalid PASSWORD_EXPIRED_NAME"); } catch (RuntimeException e) { } attributes.clear(); attributes.add(AttributeBuilder.build(OperationalAttributes.PASSWORD_EXPIRED_NAME)); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.fail("Must fail for null PASSWORD_EXPIRED_NAME"); } catch (RuntimeException e) { } attributes.clear(); attributes.add(AttributeBuilder.build(OracleConstants.ORACLE_DEF_TS_ATTR_NAME)); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.fail("Must fail for null ORACLE_DEF_TS_ATTR_NAME"); } catch (RuntimeException e) { } attributes.clear(); attributes.add(AttributeBuilder.build(OracleConstants.ORACLE_DEF_TS_ATTR_NAME, "")); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.fail("Must fail for empty ORACLE_DEF_TS_ATTR_NAME"); } catch (RuntimeException e) { } attributes = new HashSet<Attribute>(); attributes.add(AttributeBuilder.build(OracleConstants.ORACLE_TEMP_TS_ATTR_NAME)); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.fail("Must fail for null ORACLE_TEMP_TS_ATTR_NAME"); } catch (RuntimeException e) { } attributes = new HashSet<Attribute>(); attributes.add(AttributeBuilder.build(OracleConstants.ORACLE_TEMP_TS_ATTR_NAME, "")); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.fail("Must fail for empty ORACLE_TEMP_TS_ATTR_NAME"); } catch (RuntimeException e) { } attributes = new HashSet<Attribute>(); attributes.add(AttributeBuilder.build(OracleConstants.ORACLE_PROFILE_ATTR_NAME)); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.fail("Must fail for null ORACLE_PROFILE_ATTR_NAME"); } catch (RuntimeException e) { } attributes = new HashSet<Attribute>(); attributes.add(AttributeBuilder.build(OracleConstants.ORACLE_PROFILE_ATTR_NAME, "")); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.fail("Must fail for empty ORACLE_PROFILE_ATTR_NAME"); } catch (RuntimeException e) { } attributes = new HashSet<Attribute>(); caAttributes = new OracleUserAttributes.Builder(); attributes.add(AttributeBuilder.build(OracleConstants.ORACLE_DEF_TS_QUOTA_ATTR_NAME)); reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); assertEquals("Must set 0 for null quota", "0", caAttributes.getDefaultTSQuota()); attributes = new HashSet<Attribute>(); caAttributes = new OracleUserAttributes.Builder(); attributes.add(AttributeBuilder.build(OracleConstants.ORACLE_TEMP_TS_QUOTA_ATTR_NAME, "")); reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); assertEquals("Must set 0 for null quota", "0", caAttributes.getTempTSQuota()); attributes = new HashSet<Attribute>(); caAttributes = new OracleUserAttributes.Builder(); attributes.add(AttributeBuilder.buildLockOut(true)); reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); AssertJUnit.assertFalse("Enabled must be false for lock_out(true)", caAttributes .getEnable()); attributes = new HashSet<Attribute>(); caAttributes = new OracleUserAttributes.Builder(); attributes.add(AttributeBuilder.buildLockOut(false)); reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); AssertJUnit .assertTrue("Enabled must be true for lock_out(false)", caAttributes.getEnable()); attributes = new HashSet<Attribute>(); caAttributes = new OracleUserAttributes.Builder(); attributes.add(AttributeBuilder.buildEnabled(false)); attributes.add(AttributeBuilder.buildLockOut(true)); reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); AssertJUnit.assertFalse("Enabled must be false for enabled(false) and lock_out(true)", caAttributes.getEnable()); attributes = new HashSet<Attribute>(); caAttributes = new OracleUserAttributes.Builder(); attributes.add(AttributeBuilder.buildEnabled(true)); attributes.add(AttributeBuilder.buildLockOut(false)); reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); AssertJUnit.assertTrue("Enabled must be true for enabled(true) and lock_out(false)", caAttributes.getEnable()); attributes = new HashSet<Attribute>(); caAttributes = new OracleUserAttributes.Builder(); attributes.add(AttributeBuilder.buildEnabled(true)); attributes.add(AttributeBuilder.buildLockOut(true)); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.fail("Read attributes must fail for enabled(true) nad lockout(true)"); } catch (RuntimeException e) { } attributes = new HashSet<Attribute>(); caAttributes = new OracleUserAttributes.Builder(); attributes.add(AttributeBuilder.buildEnabled(false)); attributes.add(AttributeBuilder.buildLockOut(false)); try { reader.readCreateAttributes(AttributeUtil.toMap(attributes), caAttributes); Assert.fail("Read attributes must fail for enabled(false) nad lockout(false)"); } catch (RuntimeException e) { } }
void readCreateAttributes(Map<String, Attribute> map, OracleUserAttributes.Builder caAttributes) { readAuthAttributes(map, caAttributes, CreateOp.class); readRestAttributes(map, caAttributes, CreateOp.class); }
OracleAttributesReader { void readCreateAttributes(Map<String, Attribute> map, OracleUserAttributes.Builder caAttributes) { readAuthAttributes(map, caAttributes, CreateOp.class); readRestAttributes(map, caAttributes, CreateOp.class); } }
OracleAttributesReader { void readCreateAttributes(Map<String, Attribute> map, OracleUserAttributes.Builder caAttributes) { readAuthAttributes(map, caAttributes, CreateOp.class); readRestAttributes(map, caAttributes, CreateOp.class); } OracleAttributesReader(ConnectorMessages messages); }
OracleAttributesReader { void readCreateAttributes(Map<String, Attribute> map, OracleUserAttributes.Builder caAttributes) { readAuthAttributes(map, caAttributes, CreateOp.class); readRestAttributes(map, caAttributes, CreateOp.class); } OracleAttributesReader(ConnectorMessages messages);  }
OracleAttributesReader { void readCreateAttributes(Map<String, Attribute> map, OracleUserAttributes.Builder caAttributes) { readAuthAttributes(map, caAttributes, CreateOp.class); readRestAttributes(map, caAttributes, CreateOp.class); } OracleAttributesReader(ConnectorMessages messages);   }