@Test public void testAlterUser() { OracleUserAttributes.Builder attributes = new OracleUserAttributes.Builder(); attributes.setAuth(null); attributes.setUserName("user1"); attributes.setExpirePassword(true); attributes.setEnable(true); attributes.setDefaultTSQuota("-1"); UserRecord record = new UserRecord.Builder().setDefaultTableSpace("users").build(); assertEquals( "alter user \"user1\" quota unlimited on \"users\" password expire account unlock", createDefaultBuilder().buildAlterUserSt(attributes.build(), record).toString()); attributes.setEnable(null); attributes.setExpirePassword(null); attributes.setTempTableSpace("tempTS"); record = new UserRecord.Builder().setDefaultTableSpace("defTS").build(); assertEquals( "alter user \"user1\" temporary tablespace \"tempTS\" quota unlimited on \"defTS\"", createDefaultBuilder().buildAlterUserSt(attributes.build(), record).toString()); attributes = new OracleUserAttributes.Builder(); attributes.setUserName("user1"); attributes.setExpirePassword(true); assertEquals("alter user \"user1\" password expire", createDefaultBuilder() .buildAlterUserSt(attributes.build(), record).toString()); attributes = new OracleUserAttributes.Builder(); attributes.setUserName("user1"); Assert.assertNull(createDefaultBuilder().buildAlterUserSt(attributes.build(), record)); attributes = new OracleUserAttributes.Builder(); attributes.setUserName("user1"); attributes.setExpirePassword(false); attributes.setPassword(new GuardedString("newPassword".toCharArray())); assertEquals("alter user \"user1\" identified by \"newPassword\"", createDefaultBuilder() .buildAlterUserSt(attributes.build(), record).toString()); attributes.setPassword(null); record = new UserRecord.Builder().setDefaultTableSpace("users").setStatus("EXPIRED").build(); try { createDefaultBuilder().buildAlterUserSt(attributes.build(), record); Assert.fail("Must require password for unexpire"); } catch (RuntimeException e) { } record = new UserRecord.Builder().setDefaultTableSpace("users").setStatus("OPEN").build(); createDefaultBuilder().buildAlterUserSt(attributes.build(), record); }
String buildAlterUserSt(OracleUserAttributes userAttributes, UserRecord userRecord) { if (userAttributes.getUserName() == null) { throw new IllegalArgumentException("User not specified"); } if (userRecord == null) { throw new IllegalArgumentException("Must set userRecord for update"); } String ddl = generateDDL(userAttributes, UpdateOp.class, userRecord); if (ddl == null || ddl.length() == 0) { return null; } StringBuilder builder = new StringBuilder(); builder.append("alter user ").append(cs.formatToken(USER, userAttributes.getUserName())); builder.append(ddl); return builder.toString(); }
OracleCreateOrAlterStBuilder { String buildAlterUserSt(OracleUserAttributes userAttributes, UserRecord userRecord) { if (userAttributes.getUserName() == null) { throw new IllegalArgumentException("User not specified"); } if (userRecord == null) { throw new IllegalArgumentException("Must set userRecord for update"); } String ddl = generateDDL(userAttributes, UpdateOp.class, userRecord); if (ddl == null || ddl.length() == 0) { return null; } StringBuilder builder = new StringBuilder(); builder.append("alter user ").append(cs.formatToken(USER, userAttributes.getUserName())); builder.append(ddl); return builder.toString(); } }
OracleCreateOrAlterStBuilder { String buildAlterUserSt(OracleUserAttributes userAttributes, UserRecord userRecord) { if (userAttributes.getUserName() == null) { throw new IllegalArgumentException("User not specified"); } if (userRecord == null) { throw new IllegalArgumentException("Must set userRecord for update"); } String ddl = generateDDL(userAttributes, UpdateOp.class, userRecord); if (ddl == null || ddl.length() == 0) { return null; } StringBuilder builder = new StringBuilder(); builder.append("alter user ").append(cs.formatToken(USER, userAttributes.getUserName())); builder.append(ddl); return builder.toString(); } OracleCreateOrAlterStBuilder(OracleCaseSensitivitySetup cs, ConnectorMessages cm,
            ExtraAttributesPolicySetup extraAttributesPolicySetup);   OracleCreateOrAlterStBuilder(OracleConfiguration cfg); }
OracleCreateOrAlterStBuilder { String buildAlterUserSt(OracleUserAttributes userAttributes, UserRecord userRecord) { if (userAttributes.getUserName() == null) { throw new IllegalArgumentException("User not specified"); } if (userRecord == null) { throw new IllegalArgumentException("Must set userRecord for update"); } String ddl = generateDDL(userAttributes, UpdateOp.class, userRecord); if (ddl == null || ddl.length() == 0) { return null; } StringBuilder builder = new StringBuilder(); builder.append("alter user ").append(cs.formatToken(USER, userAttributes.getUserName())); builder.append(ddl); return builder.toString(); } OracleCreateOrAlterStBuilder(OracleCaseSensitivitySetup cs, ConnectorMessages cm,
            ExtraAttributesPolicySetup extraAttributesPolicySetup);   OracleCreateOrAlterStBuilder(OracleConfiguration cfg);  }
OracleCreateOrAlterStBuilder { String buildAlterUserSt(OracleUserAttributes userAttributes, UserRecord userRecord) { if (userAttributes.getUserName() == null) { throw new IllegalArgumentException("User not specified"); } if (userRecord == null) { throw new IllegalArgumentException("Must set userRecord for update"); } String ddl = generateDDL(userAttributes, UpdateOp.class, userRecord); if (ddl == null || ddl.length() == 0) { return null; } StringBuilder builder = new StringBuilder(); builder.append("alter user ").append(cs.formatToken(USER, userAttributes.getUserName())); builder.append(ddl); return builder.toString(); } OracleCreateOrAlterStBuilder(OracleCaseSensitivitySetup cs, ConnectorMessages cm,
            ExtraAttributesPolicySetup extraAttributesPolicySetup);   OracleCreateOrAlterStBuilder(OracleConfiguration cfg);   }