Skip to content

Commit

Permalink
Adding JUnit. Fixes apolloconfig#3874
Browse files Browse the repository at this point in the history
  • Loading branch information
ayush0407 committed Mar 19, 2022
1 parent eb78ceb commit 2f3be72
Showing 1 changed file with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
package com.ctrip.framework.apollo.biz.utils;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.ctrip.framework.apollo.biz.MockBeanFactory;
import com.ctrip.framework.apollo.biz.entity.Item;
import org.junit.Before;
import org.junit.Test;

import com.ctrip.framework.apollo.biz.MockBeanFactory;
import com.ctrip.framework.apollo.biz.entity.Item;

/**
* @author jian.tan
*/
Expand All @@ -32,23 +34,43 @@ public class ConfigChangeContentBuilderTest {

private final ConfigChangeContentBuilder configChangeContentBuilder = new ConfigChangeContentBuilder();
private String configString;

private Item createdItem;
private Item updatedItem;
private Item updatedItemFalseCheck;
private Item createdItemFalseCheck;
@Before
public void initConfig() {

Item createdItem = MockBeanFactory.mockItem(1, 1, "timeout", "100", 1);
Item updatedItem = MockBeanFactory.mockItem(1, 1, "timeout", "1001", 1);
createdItem = MockBeanFactory.mockItem(1, 1, "timeout", "100", 1);
updatedItem = MockBeanFactory.mockItem(1, 1, "timeout", "1001", 1);
updatedItemFalseCheck = MockBeanFactory.mockItem(1, 1, "timeout", "100", 1);
createdItemFalseCheck = MockBeanFactory.mockItem(1, 1, "", "100", 1);

configChangeContentBuilder.createItem(createdItem);
configChangeContentBuilder.createItem(createdItemFalseCheck);
configChangeContentBuilder.updateItem(createdItem, updatedItem);
configChangeContentBuilder.updateItem(createdItem, updatedItemFalseCheck);
configChangeContentBuilder.deleteItem(updatedItem);
configChangeContentBuilder.deleteItem(createdItemFalseCheck);

configString = configChangeContentBuilder.build();
}

@Test
public void testHasContent() {
assertTrue(configChangeContentBuilder.hasContent());
assertTrue(configChangeContentBuilder.hasContent());
configChangeContentBuilder.getCreateItems().clear();
assertTrue(configChangeContentBuilder.hasContent());
configChangeContentBuilder.getUpdateItems().clear();
assertTrue(configChangeContentBuilder.hasContent());
}

@Test
public void testHasContentFalseCheck() {
configChangeContentBuilder.getCreateItems().clear();
configChangeContentBuilder.getUpdateItems().clear();
configChangeContentBuilder.getDeleteItems().clear();
assertFalse(configChangeContentBuilder.hasContent());
}

@Test
Expand Down

0 comments on commit 2f3be72

Please sign in to comment.