Skip to content

fix: Expose ID and destination type of LogDestinationName publicly #796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public final class LogDestinationName extends Option {
private static final long serialVersionUID = 7944256748441111191L;

enum DestinationType implements Option.OptionType {
public enum DestinationType implements Option.OptionType {
PROJECT,
FOLDER,
ORGANIZATION,
Expand Down Expand Up @@ -109,6 +109,16 @@ public LogName toLogName(String logId) {
return null;
}

/** Returns ID value associated with {@code LogDestinationName} object */
public String getId() {
return getValue().toString();
}

/** Returns destination type option value associated with {@code LogDestinationName} object */
public DestinationType getDestinationType() {
return getOptionType();
}

/** Creates a {@code LogDestinationName} object from given {@code LogName}. */
public static LogDestinationName fromLogName(LogName logName) {
if (logName == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,25 @@ public void testWriteOptionWithDestination() {
WriteOption writeOption = WriteOption.destination(LogDestinationName.project(PROJECT_NAME));
LogDestinationName resource = (LogDestinationName) writeOption.getValue();
assertEquals(WriteOption.OptionType.LOG_DESTINATION, writeOption.getOptionType());
assertEquals(LogDestinationName.DestinationType.PROJECT, resource.getOptionType());
assertEquals(PROJECT_NAME, resource.getValue());
assertEquals(LogDestinationName.DestinationType.PROJECT, resource.getDestinationType());
assertEquals(PROJECT_NAME, resource.getId());

writeOption = WriteOption.destination(LogDestinationName.billingAccount(BILLING_NAME));
resource = (LogDestinationName) writeOption.getValue();
assertEquals(WriteOption.OptionType.LOG_DESTINATION, writeOption.getOptionType());
assertEquals(LogDestinationName.DestinationType.BILLINGACCOUNT, resource.getOptionType());
assertEquals(BILLING_NAME, resource.getValue());
assertEquals(LogDestinationName.DestinationType.BILLINGACCOUNT, resource.getDestinationType());
assertEquals(BILLING_NAME, resource.getId());

writeOption = WriteOption.destination(LogDestinationName.folder(FOLDER_NAME));
resource = (LogDestinationName) writeOption.getValue();
assertEquals(WriteOption.OptionType.LOG_DESTINATION, writeOption.getOptionType());
assertEquals(LogDestinationName.DestinationType.FOLDER, resource.getOptionType());
assertEquals(FOLDER_NAME, resource.getValue());
assertEquals(LogDestinationName.DestinationType.FOLDER, resource.getDestinationType());
assertEquals(FOLDER_NAME, resource.getId());

writeOption = WriteOption.destination(LogDestinationName.organization(ORGANIZATION_NAME));
resource = (LogDestinationName) writeOption.getValue();
assertEquals(WriteOption.OptionType.LOG_DESTINATION, writeOption.getOptionType());
assertEquals(LogDestinationName.DestinationType.ORGANIZATION, resource.getOptionType());
assertEquals(ORGANIZATION_NAME, resource.getValue());
assertEquals(LogDestinationName.DestinationType.ORGANIZATION, resource.getDestinationType());
assertEquals(ORGANIZATION_NAME, resource.getId());
}
}