Skip to content

Commit

Permalink
Change return type of method: defaultProperties: List
Browse files Browse the repository at this point in the history
  • Loading branch information
lazmond3 committed Dec 9, 2021
1 parent 3efe319 commit c17b3c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public static CentralDogmaPropertySupplier register(CentralDogma centralDogma, S
public static CentralDogmaPropertySupplier register(CentralDogma centralDogma, String project,
String repository, String filename,
PropertySupplier supplier) {
List<Property<?>> properties = defaultPropertiesAsList().stream().map(defaultProperty -> {
List<Property<?>> properties = defaultProperties().stream().map(defaultProperty -> {
if (supplier.getProperty(defaultProperty.definition()).isPresent()) {
return supplier.getProperty(defaultProperty.definition()).get();
} else {
Expand All @@ -166,7 +166,7 @@ public static CentralDogmaPropertySupplier register(CentralDogma centralDogma, S
private static void createPropertyFile(CentralDogma centralDogma, String project,
String repository, String fileName) {
createPropertyFile(centralDogma,
project, repository, fileName, defaultPropertiesAsList());
project, repository, fileName, defaultProperties());
}

private static void createPropertyFile(CentralDogma centralDogma, String project,
Expand Down Expand Up @@ -251,7 +251,8 @@ private static long remainingTime(long totalTime, long startedTime) {
return totalTime - (System.currentTimeMillis() - startedTime);
}

private static JsonNode convertPropertyListToJsonNode(List<Property<?>> properties) {
// visible for testing
static JsonNode convertPropertyListToJsonNode(List<Property<?>> properties) {
final ObjectNode propertiesObjectNode = objectMapper.createObjectNode();
properties.forEach(
property -> {
Expand All @@ -265,18 +266,7 @@ private static JsonNode convertPropertyListToJsonNode(List<Property<?>> properti
}

// visible for testing
static JsonNode defaultProperties() {
final ObjectNode properties = objectMapper.createObjectNode();
ProcessorProperties.PROPERTY_DEFINITIONS
.forEach(definition -> properties.set(definition.name(),
objectMapper.valueToTree(definition.defaultValue()))
);

return properties;
}

// visible for testing
static List<Property<?>> defaultPropertiesAsList() {
static List<Property<?>> defaultProperties() {
List<Property<?>> properties = new ArrayList<>();
ProcessorProperties.PROPERTY_DEFINITIONS
.forEach(definition -> properties.add(new DynamicProperty(definition)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public class CentralDogmaPropertySupplierIntegrationTest {
private static final String REPOSITORY_NAME = "repo";
private static final String FILENAME = "/subscription.json";

private JsonNode defaultProperties() {
return CentralDogmaPropertySupplier.convertPropertyListToJsonNode(
CentralDogmaPropertySupplier.defaultProperties());
}

@Test(timeout = 50000)
public void testCDIntegration() throws InterruptedException {
CentralDogma client = centralDogmaRule.client();
Expand Down Expand Up @@ -131,7 +136,7 @@ public void testCDRegisterSuccess() {
Entry<JsonNode> prop = client.getFile(PROJECT_NAME, REPOSITORY_NAME,
Revision.HEAD, Query.ofJson(FILENAME)).join();

assertEquals(CentralDogmaPropertySupplier.defaultProperties().asText(),
assertEquals(defaultProperties().asText(),
prop.content().asText());
}

Expand Down Expand Up @@ -174,7 +179,7 @@ public void testCDRegisterConflict() throws Exception {
return i.callRealMethod();
}).when(userA)
.push(eq(PROJECT_NAME), eq(REPOSITORY_NAME), any(), any(),
eq(Change.ofJsonUpsert(FILENAME, CentralDogmaPropertySupplier.defaultProperties())));
eq(Change.ofJsonUpsert(FILENAME, defaultProperties())));

ExecutorService service = Executors.newFixedThreadPool(2);
service.submit(() -> CentralDogmaPropertySupplier
Expand Down

0 comments on commit c17b3c7

Please sign in to comment.