Skip to content

Commit

Permalink
test: Add test for enum generation with argument builder
Browse files Browse the repository at this point in the history
  • Loading branch information
aurambaj committed Jan 12, 2024
1 parent a80c607 commit b2aa1d4
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ public void valid() {
checkGenerationSuccessful(compilation);
}

@Test
public void validArgumentBuilder() {
assumeTrue(shouldUseOldGeneratedAnnotation());
Compilation compilation = defaultCompile();
checkGenerationSuccessful(compilation);
}

@Test
public void validJava9() {
assumeFalse(shouldUseOldGeneratedAnnotation());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.pinterest.l10nmessages.L10nPropertiesProcessorTest_IO.valid;

import com.pinterest.l10nmessages.EnumType;
import com.pinterest.l10nmessages.L10nProperties;

@L10nProperties(baseName = "com.pinterest.l10nmessages.L10nPropertiesProcessorTest_IO.validArgumentBuilder.TestMessages",
enumType = EnumType.WITH_ARGUMENT_BUILDERS)
public class TestApp {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.pinterest.l10nmessages.L10nPropertiesProcessorTest_IO.validArgumentBuilder;

import com.pinterest.l10nmessages.FormatContext;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.annotation.Generated;

@Generated("com.pinterest.l10nmessages.L10nPropertiesProcessor")
public enum TestMessages {
hello_user("hello_user");

public static final String BASENAME = "com.pinterest.l10nmessages.L10nPropertiesProcessorTest_IO.validArgumentBuilder.TestMessages";
public static final String MESSAGE_FORMAT_ADAPTER_PROVIDERS = "AUTO";

private String key;

TestMessages(String key) {
this.key = key;
}

@Override
public String toString() {
return key;
}

public static class FC_hello_user implements FormatContext<TestMessages> {
Map<String, Object> map = new LinkedHashMap<>();

@Override
public TestMessages getKey() {
return hello_user;
}

@Override
public Map<String, Object> getArguments() {
return map;
}

public FC_hello_user username(Object value) {
map.put("username", value);
return this;
}
}

public static FC_hello_user hello_user() {
return new FC_hello_user();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello_user=Hello {username}

0 comments on commit b2aa1d4

Please sign in to comment.