Skip to content
This repository has been archived by the owner on Dec 22, 2021. It is now read-only.

Commit

Permalink
[RELEASE]merging 'release-1.9' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
drferreira committed Nov 5, 2019
2 parents 653f3c4 + 25a9c1c commit de8eae9
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 83 deletions.
6 changes: 3 additions & 3 deletions survey-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
<target>1.8</target>
</configuration>
</plugin>
<!-- * Maven Plugin : Control Workflow Development Team * - Start Feature
: mvn jgitflow:feature-start * - Finish Feature : mvn jgitflow:feature-finish
* - Start Hotfix : mvn jgitflow:hotfix-start * - Finish Hotfix : mvn jgitflow:hotfix-finish
<!-- * Maven Plugin : Control Workflow Development Team * - Start Feature
: mvn jgitflow:feature-start * - Finish Feature : mvn jgitflow:feature-finish
* - Start Hotfix : mvn jgitflow:hotfix-start * - Finish Hotfix : mvn jgitflow:hotfix-finish
* - Start Release : mvn jgitflow:release-start * - Finish Release : mvn jgitflow:release-finish -->
<plugin>
<groupId>external.atlassian.jgitflow</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.ccem.otus.survey.template.item.questions.fillingRules.Options;
import org.ccem.otus.survey.template.item.questions.questionOption.OptionsItem;
import org.ccem.otus.survey.template.item.questions.selectable.CheckboxQuestion;
import org.ccem.otus.survey.template.item.surveyitemgroup.SurveyItemGroup;
import org.ccem.otus.survey.template.metainfo.MetaInfo;
import org.ccem.otus.survey.template.navigation.Navigation;
import org.ccem.otus.survey.template.utils.adapters.ImmutableDateAdapter;
Expand All @@ -35,9 +36,10 @@ public class SurveyTemplate {
public String objectType;
public String oid;
public Identity identity;
public MetaInfo metainfo;
public List<DataSourceDefinition> dataSources;
public List<StaticVariableDefinition> staticVariableList;
public MetaInfo metainfo;
public List<SurveyItemGroup> surveyItemGroupList;
public List<SurveyItem> itemContainer;
public List<Navigation> navigationList;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.ccem.otus.survey.template.item.surveyitemgroup;


import java.util.List;

public class SurveyItemGroup {
public String objectType;
public String start;
public String end;
public List<SurveyItemGroupMember> members;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.ccem.otus.survey.template.item.surveyitemgroup;

public class SurveyItemGroupMember {
public String id;
public String position;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,84 +19,86 @@
import com.google.gson.Gson;

public class SurveyTemplateTest {
private SurveyTemplate survey;

@Before
public void setUp() {
String json = ""
+ "{\"extents\": \"StudioObject\","
+ "\"objectType\": \"Survey\","
+ "\"oid\": \"dXNlclVVSUQ6W3VuZGVmaW5lZF1zdXJ2ZXlVVUlEOls3MDZlMTE2MC02M2I5LTExZTYtOWJjNy0xNWVhN2RkZDA4NTZdcmVwb3NpdG9yeVVVSUQ6WyBOb3QgZG9uZSB5ZXQgXQ==\","
+ "\"identity\": {},"
+ "\"staticVariableList\": [],"
+ "\"metainfo\": {},"
+ "\"itemContainer\": [],"
+ "\"navigationList\": []}";

survey = new Gson().fromJson(json, SurveyTemplate.class);
}

@Test
public void should_deserialize_correctly_Survey_Json() {
assertEquals("StudioObject", survey.extents);
assertEquals("Survey", survey.objectType);
assertEquals("dXNlclVVSUQ6W3VuZGVmaW5lZF1zdXJ2ZXlVVUlEOls3MDZlMTE2MC02M2I5LTExZTYtOWJjNy0xNWVhN2RkZDA4NTZdcmVwb3NpdG9yeVVVSUQ6WyBOb3QgZG9uZSB5ZXQgXQ==", survey.oid);

assertTrue(survey.identity instanceof Identity);
assertTrue(survey.metainfo instanceof MetaInfo);
assertTrue(survey.staticVariableList instanceof List<?>);
assertTrue(survey.itemContainer instanceof List<?>);
assertTrue(survey.navigationList instanceof List<?>);
}

@Test
public void should_return_customIds_all_items(){
List<SurveyItem> surveyItems = new ArrayList<>();
surveyItems.add(buildSurveyItem("ID1"));
surveyItems.add(buildSurveyItem("ID2"));
surveyItems.add(buildSurveyItem("ID3"));

SurveyTemplate surveyTemplate = new SurveyTemplate();
surveyTemplate.itemContainer = surveyItems;

List<String> foundedIds = surveyTemplate.getCustomIdItems();
Assert.assertFalse(foundedIds.isEmpty());
Assert.assertEquals(foundedIds.get(0), "ID1");
Assert.assertEquals(foundedIds.get(1), "ID2");
Assert.assertEquals(foundedIds.get(2), "ID3");
}

@Test
public void should_return_customIdsOption_all_QuestionCheckbox(){
List<SurveyItem> surveyItems = new ArrayList<>();
surveyItems.add(buildCheckboxQuestion("ID1a"));
surveyItems.add(buildCheckboxQuestion("ID2b"));
surveyItems.add(buildCheckboxQuestion("ID3c"));
surveyItems.add(buildCheckboxQuestion("ID4d"));

SurveyTemplate surveyTemplate = new SurveyTemplate();
surveyTemplate.itemContainer = surveyItems;

List<String> foundedIds = surveyTemplate.getCustomIdOptions();
Assert.assertFalse(foundedIds.isEmpty());
Assert.assertEquals(foundedIds.get(0), "ID1a");
Assert.assertEquals(foundedIds.get(1), "ID2b");
Assert.assertEquals(foundedIds.get(2), "ID3c");
Assert.assertEquals(foundedIds.get(3), "ID4d");
}

private CheckboxQuestion buildCheckboxQuestion(String customIdOption){
CheckboxQuestion checkboxQuestion = new CheckboxQuestion();
CheckboxOption checkboxOption = new CheckboxOption();
checkboxOption.customOptionID = customIdOption;
checkboxQuestion.options = Arrays.asList(checkboxOption);
return checkboxQuestion;
}

private SurveyItem buildSurveyItem(String customId){
SurveyItem surveyItem = new SurveyItem();
surveyItem.customID = customId;
return surveyItem;
}
private SurveyTemplate survey;

@Before
public void setUp() {
String json = ""
+ "{\"extents\": \"StudioObject\","
+ "\"objectType\": \"Survey\","
+ "\"oid\": \"dXNlclVVSUQ6W3VuZGVmaW5lZF1zdXJ2ZXlVVUlEOls3MDZlMTE2MC02M2I5LTExZTYtOWJjNy0xNWVhN2RkZDA4NTZdcmVwb3NpdG9yeVVVSUQ6WyBOb3QgZG9uZSB5ZXQgXQ==\","
+ "\"identity\": {},"
+ "\"metainfo\": {},"
+ "\"staticVariableList\": [],"
+ "\"surveyItemGroupList\": [],"
+ "\"itemContainer\": [],"
+ "\"navigationList\": []}";

survey = new Gson().fromJson(json, SurveyTemplate.class);
}

@Test
public void should_deserialize_correctly_Survey_Json() {
assertEquals("StudioObject", survey.extents);
assertEquals("Survey", survey.objectType);
assertEquals("dXNlclVVSUQ6W3VuZGVmaW5lZF1zdXJ2ZXlVVUlEOls3MDZlMTE2MC02M2I5LTExZTYtOWJjNy0xNWVhN2RkZDA4NTZdcmVwb3NpdG9yeVVVSUQ6WyBOb3QgZG9uZSB5ZXQgXQ==", survey.oid);

assertTrue(survey.identity instanceof Identity);
assertTrue(survey.metainfo instanceof MetaInfo);
assertTrue(survey.staticVariableList instanceof List<?>);
assertTrue(survey.surveyItemGroupList instanceof List<?>);
assertTrue(survey.itemContainer instanceof List<?>);
assertTrue(survey.navigationList instanceof List<?>);
}

@Test
public void should_return_customIds_all_items(){
List<SurveyItem> surveyItems = new ArrayList<>();
surveyItems.add(buildSurveyItem("ID1"));
surveyItems.add(buildSurveyItem("ID2"));
surveyItems.add(buildSurveyItem("ID3"));

SurveyTemplate surveyTemplate = new SurveyTemplate();
surveyTemplate.itemContainer = surveyItems;

List<String> foundedIds = surveyTemplate.getCustomIdItems();
Assert.assertFalse(foundedIds.isEmpty());
Assert.assertEquals(foundedIds.get(0), "ID1");
Assert.assertEquals(foundedIds.get(1), "ID2");
Assert.assertEquals(foundedIds.get(2), "ID3");
}

@Test
public void should_return_customIdsOption_all_QuestionCheckbox(){
List<SurveyItem> surveyItems = new ArrayList<>();
surveyItems.add(buildCheckboxQuestion("ID1a"));
surveyItems.add(buildCheckboxQuestion("ID2b"));
surveyItems.add(buildCheckboxQuestion("ID3c"));
surveyItems.add(buildCheckboxQuestion("ID4d"));

SurveyTemplate surveyTemplate = new SurveyTemplate();
surveyTemplate.itemContainer = surveyItems;

List<String> foundedIds = surveyTemplate.getCustomIdOptions();
Assert.assertFalse(foundedIds.isEmpty());
Assert.assertEquals(foundedIds.get(0), "ID1a");
Assert.assertEquals(foundedIds.get(1), "ID2b");
Assert.assertEquals(foundedIds.get(2), "ID3c");
Assert.assertEquals(foundedIds.get(3), "ID4d");
}

private CheckboxQuestion buildCheckboxQuestion(String customIdOption){
CheckboxQuestion checkboxQuestion = new CheckboxQuestion();
CheckboxOption checkboxOption = new CheckboxOption();
checkboxOption.customOptionID = customIdOption;
checkboxQuestion.options = Arrays.asList(checkboxOption);
return checkboxQuestion;
}

private SurveyItem buildSurveyItem(String customId){
SurveyItem surveyItem = new SurveyItem();
surveyItem.customID = customId;
return surveyItem;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.ccem.otus.survey.template.item.surveyitemgroup;

import com.google.gson.Gson;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.modules.junit4.PowerMockRunner;

import static org.junit.Assert.assertEquals;

@RunWith(PowerMockRunner.class)
public class SurveyItemGroupMemberTest {
private SurveyItemGroupMember surveyItemGroupMember;

@Before
public void setUp() {
String json = ""
+ "{\"id\": \"DIC1\","
+ "\"position\": \"start\"}";

surveyItemGroupMember = new Gson().fromJson(json, SurveyItemGroupMember.class);
}

@Test
public void should_parse_correctly_id_attribute(){
assertEquals("DIC1",surveyItemGroupMember.id);
}

@Test
public void should_parse_correctly_position_attribute(){
assertEquals("start",surveyItemGroupMember.position);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.ccem.otus.survey.template.item.surveyitemgroup;

import com.google.gson.Gson;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.modules.junit4.PowerMockRunner;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

import static org.junit.Assert.*;

@RunWith(PowerMockRunner.class)
public class SurveyItemGroupTest {
private SurveyItemGroup surveyItemGroup;

@Before
public void setUp() {
String json = ""
+ "{\"objectType\": \"SurveyItemGroup\","
+ "\"start\": \"DIC1\","
+ "\"end\": \"DIC3\","
+ "\"members\":[]}";

surveyItemGroup = new Gson().fromJson(json, SurveyItemGroup.class);
}

@Test
public void should_parse_correctly_objectType_attribute(){
assertEquals("SurveyItemGroup",surveyItemGroup.objectType);
}

@Test
public void should_parse_correctly_start_attribute(){
assertEquals("DIC1",surveyItemGroup.start);
}

@Test
public void should_parse_correctly_end_attribute(){
assertEquals("DIC3",surveyItemGroup.end);
}

@Test
public void should_parse_correctly_members_attribute(){
assertTrue(surveyItemGroup.members instanceof List<?>);
}
}

0 comments on commit de8eae9

Please sign in to comment.