Java Code Examples for com.google.gson.internal.LinkedHashTreeMap

The following examples show how to use com.google.gson.internal.LinkedHashTreeMap. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
public void checkValidationWithValidValues () throws Exception {
    Map<String, Object> config = new LinkedHashTreeMap<String, Object>();
    List<Map<String, Object>> errors = new ArrayList<Map<String, Object>>();

    Map<String, String> dummyUrl = new LinkedHashTreeMap<String, String>();
    dummyUrl.put("value", "http://localhost:8153");

    Map<String, String> dummyToken = new LinkedHashTreeMap<String, String>();
    dummyToken.put("value", "abcdef");

    config.put(PLUGIN_SETTINGS_SERVER_BASE_URL, dummyUrl);
    config.put(PLUGIN_SETTINGS_END_POINT, dummyUrl);
    config.put(PLUGIN_SETTINGS_OAUTH_TOKEN, dummyToken);

    List<Map<String, Object>> returnedErrors = provider.validateConfig(config);
    assertEquals(errors, returnedErrors);
}
 
Example 2
@Test
public void checkValidationWithInvalidValues () throws Exception {
    Map<String, Object> config = new LinkedHashTreeMap<String, Object>();

    Map<String, String> dummyUrl = new LinkedHashTreeMap<String, String>();
    dummyUrl.put("value", "localhost:8153");

    Map<String, String> dummyToken = new LinkedHashTreeMap<String, String>();
    dummyToken.put("value", "");

    config.put(PLUGIN_SETTINGS_SERVER_BASE_URL, dummyUrl);
    config.put(PLUGIN_SETTINGS_END_POINT, dummyUrl);
    config.put(PLUGIN_SETTINGS_OAUTH_TOKEN, dummyToken);

    List<Map<String, Object>> returnedErrors = provider.validateConfig(config);
    assertEquals(3, returnedErrors.size());
}
 
Example 3
Source Project: vespa   Source File: FixedQuery.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * build the query map from the query
 *
 * @return the query map
 */
public Map<String, String> buildQueryMap() {
    if (queryMap != null) {
        return queryMap;
    }

    assignIndex();

    StringBuilder sb = new StringBuilder();
    sb.append("select ")
        .append(endQuery.queryChain.getSelect())
        .append(" from ")
        .append(endQuery.queryChain.getSources())
        .append(" where ")
        .append(endQuery.queryChain);

    if (!"".equals(endQuery.toString())) {
        sb.append(' ').append(endQuery);
    }
    sb.append(";");

    queryMap = new LinkedHashTreeMap<>(); // for the order
    queryMap.put("yql", sb.toString());
    queryMap.putAll(others);
    queryMap.putAll(getUserInputs());
    return queryMap;
}
 
Example 4
Source Project: gocd-build-status-notifier   Source File: GitLabProvider.java    License: Apache License 2.0 5 votes vote down vote up
private String getValueFromPluginSettings(Object values) {
    if (values == null) {
        return "";
    }
    Map<String, String> vals = (LinkedHashTreeMap<String, String>)values;
    String ret = vals.get("value");
    if (ret == null) {
        return "";
    }
    return ret;
}
 
Example 5
/**
 * 10個 story,沒有 task
 * filter 條件
 * - 第1個 sprint
 * - 所有人 ALL
 */
public void testGetTaskBoardStoryTaskList_2() throws Exception {
	// Sprint 加入10個 Story
	int storyCount = 10;
	AddStoryToSprint ASTS = new AddStoryToSprint(storyCount, 1, mCS, mCP, "EST");
	ASTS.exe();

	// ================ set request info ========================
	String projectName = mProject.getName();
	request.setHeader("Referer", "?PID=" + projectName);
	addRequestParameter("UserID", "ALL");
	addRequestParameter("sprintID", "1");

	// ================ set session info ========================
	request.getSession().setAttribute("UserSession", mConfig.getUserSession());

	// ================ 執行 action ======================
	actionPerform();

	// ================ assert ======================
	verifyNoActionErrors();
	verifyNoActionMessages();
	
	String result = response.getWriterBuffer().toString();
	HashMap<String, Object> resultMap = mGson.fromJson(result, HashMap.class);
	ArrayList<LinkedHashTreeMap<String, Object>> storyList = (ArrayList<LinkedHashTreeMap<String, Object>>) resultMap.get("Stories");
	Number total = (Number) resultMap.get("Total");
	ArrayList<StoryObject> expectedStories = ASTS.getStories();
	

	assertEquals(true, resultMap.get("success"));
	assertEquals(storyCount, total.intValue());
	for (int i = 0; i < storyCount; i++) {
		StoryObject story;
		story = expectedStories.get(i);
		assertEquals(String.valueOf(story.getId()), storyList.get(i).get("Id"));
		assertEquals(story.getName(), storyList.get(i).get("Name"));
		assertEquals(String.valueOf(story.getValue()), storyList.get(i).get("Value"));
		assertEquals(String.valueOf(story.getEstimate()), storyList.get(i).get("Estimate"));
		assertEquals(String.valueOf(story.getImportance()), storyList.get(i).get("Importance"));
		assertEquals("", storyList.get(i).get("Tag"));
		assertEquals(story.getStatusString(), storyList.get(i).get("Status"));
		assertEquals(story.getNotes(), storyList.get(i).get("Notes"));
		assertEquals(story.getHowToDemo(), storyList.get(i).get("HowToDemo"));
		assertEquals(String.valueOf(mCS.getSprintsId().get(0)), storyList.get(i).get("Sprint"));
		assertEquals(false, storyList.get(i).get("Attach"));
		assertEquals(story.getAttachFiles(), storyList.get(i).get("AttachFileList"));
		assertEquals(new ArrayList<LinkedHashTreeMap>(), storyList.get(i).get("Tasks"));
	}
}
 
Example 6
/**
 * 測試 Story 的 burndown chart 在都沒有 done 的情況下的圖資料是否正確
 */
public void testGetSprintBurndownChartData_Story_1() throws Exception {
	final int STORY_COUNT = 2, STORY_EST = 5;
	// Sprint加入2個Story
	AddStoryToSprint ASTS = new AddStoryToSprint(STORY_COUNT, STORY_EST, mCS, mCP, CreateProductBacklog.COLUMN_TYPE_EST);
	ASTS.exe();

	// 拿出 sprint 的每一天日期放在 idealPointArray 當 expecte 天數
	SprintBacklogLogic sprintBacklogLogic = new SprintBacklogLogic(mProject, mCS.getSprintsId().get(0));
	SprintBacklogMapper SprintBacklogMapper = sprintBacklogLogic.getSprintBacklogMapper();
	TaskBoard taskBoard = new TaskBoard(sprintBacklogLogic, SprintBacklogMapper);
	LinkedHashMap<Date, Double> ideal = taskBoard.getStoryIdealPointMap();
	DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
	Object[] idealPointArray = ideal.keySet().toArray();

	// ================ set request info ========================
	request.setHeader("Referer", "?PID=" + mProject.getName());
	addRequestParameter("SprintID", String.valueOf(mCS.getSprintsId().get(0)));
	addRequestParameter("Type", "story");

	// ================ set session info ========================s
	request.getSession().setAttribute("UserSession", mConfig.getUserSession());

	// ================ 執行 action ======================
	actionPerform();

	// ================ assert ======================
	verifyNoActionErrors();
	verifyNoActionMessages();
	String result = response.getWriterBuffer().toString();
	HashMap resultMap = mGson.fromJson(result, HashMap.class);
	ArrayList<LinkedHashTreeMap<String, Object>> points = (ArrayList<LinkedHashTreeMap<String, Object>>) resultMap.get("Points");
	Double totalStoryPoint = new Integer(STORY_COUNT * STORY_EST).doubleValue();
	// 算出每一天ideal point的遞減值
	Double periodPoint = totalStoryPoint / (points.size() - 1);
	assertEquals(true, resultMap.get("success"));
	for (int i = 0; i < points.size(); i++) {
		assertEquals(formatter.format(idealPointArray[i]), points.get(i).get("Date"));
		assertEquals(totalStoryPoint - periodPoint * i, points.get(i).get("IdealPoint"));
		// 只有第一天有real point其他因為時間尚未到,所以不會有real point
		if (i == 0) {
			assertEquals(totalStoryPoint, points.get(i).get("RealPoint"));
		} else {
			assertEquals("null", points.get(i).get("RealPoint"));
		}
	}
}
 
Example 7
/**
 * 測試Story的burndown chart當有story拉到done時,資料是否正確
 */
public void testGetSprintBurndownChartData_Story_2() throws Exception {
	final int STORY_COUNT = 2, STORY_EST = 5;
	// Sprint加入2個Story
	AddStoryToSprint ASTS = new AddStoryToSprint(STORY_COUNT, STORY_EST, mCS, mCP, CreateProductBacklog.COLUMN_TYPE_EST);
	ASTS.exe();

	// 拿出sprint的每一天日期
	SprintBacklogLogic sprintBacklogLogic = new SprintBacklogLogic(mProject, mCS.getSprintsId().get(0));
	SprintBacklogMapper SprintBacklogMapper = sprintBacklogLogic.getSprintBacklogMapper();
	TaskBoard taskBoard = new TaskBoard(sprintBacklogLogic, SprintBacklogMapper);
	LinkedHashMap<Date, Double> ideal = taskBoard.getStoryIdealPointMap();
	DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
	Object[] idealPointArray = ideal.keySet().toArray();
	// 將story移到done
	sprintBacklogLogic.closeStory(ASTS.getStories().get(0).getId(), ASTS.getStories().get(0).getName(), "", "");

	// ================ set request info ========================
	request.setHeader("Referer", "?PID=" + mProject.getName());
	addRequestParameter("SprintID",  String.valueOf(mCS.getSprintsId().get(0)));
	addRequestParameter("Type", "story");

	// ================ set session info ========================s
	request.getSession().setAttribute("UserSession", mConfig.getUserSession());

	// ================ 執行 action ======================
	actionPerform();

	// ================ assert ======================
	verifyNoActionErrors();
	verifyNoActionMessages();
	String result = response.getWriterBuffer().toString();
	HashMap resultMap = mGson.fromJson(result, HashMap.class);
	ArrayList<LinkedHashTreeMap<String, Object>> points = (ArrayList<LinkedHashTreeMap<String, Object>>) resultMap.get("Points");
	// 由於done了一個story因此減掉一個story的est
	Double totalStoryPoint = new Integer(STORY_COUNT * STORY_EST).doubleValue() - STORY_EST;
	Double periodPoint = totalStoryPoint / (points.size() - 1);
	assertEquals(true, resultMap.get("success"));
	for (int i = 0; i < points.size(); i++) {
		assertEquals(formatter.format(idealPointArray[i]), points.get(i).get("Date"));
		assertEquals(totalStoryPoint - periodPoint * i, points.get(i).get("IdealPoint"));
		if (i == 0) {
			assertEquals(totalStoryPoint, points.get(i).get("RealPoint"));
		} else {
			assertEquals("null", points.get(i).get("RealPoint"));
		}
	}
}
 
Example 8
/**
 * 測試Task的burndown chart在都沒有done的情況下的圖資料是否正確
 */
public void testGetSprintBurndownChartData_Task_1() throws Exception {
	final int STORY_COUNT = 2, TASK_COUNT = 2, STORY_EST = 5, TASK_EST = 5;
	// Sprint加入2個Story
	AddStoryToSprint ASTS = new AddStoryToSprint(STORY_COUNT, STORY_EST, mCS, mCP, CreateProductBacklog.COLUMN_TYPE_EST);
	ASTS.exe();

	// 每個Story加入2個task
	AddTaskToStory ATTS = new AddTaskToStory(TASK_COUNT, TASK_EST, ASTS, mCP);
	ATTS.exe();

	// ================ set request info ========================
	request.setHeader("Referer", "?PID=" + mProject.getName());
	addRequestParameter("SprintID", String.valueOf(mCS.getSprintsId().get(0)));
	addRequestParameter("Type", "task");

	// ================ set session info ========================s
	request.getSession().setAttribute("UserSession", mConfig.getUserSession());

	// ================ 執行 action ======================
	actionPerform();

	// 拿出sprint的每一天日期放在idealPointArray當expecte 天數
	SprintBacklogLogic sprintBacklogLogic = new SprintBacklogLogic(mProject, mCS.getSprintsId().get(0));
	SprintBacklogMapper SprintBacklogMapper = sprintBacklogLogic.getSprintBacklogMapper();
	TaskBoard taskBoard = new TaskBoard(sprintBacklogLogic, SprintBacklogMapper);
	LinkedHashMap<Date, Double> ideal = taskBoard.getStoryIdealPointMap();
	DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
	Object[] idealPointArray = ideal.keySet().toArray();

	// ================ assert ======================
	verifyNoActionErrors();
	verifyNoActionMessages();
	String result = response.getWriterBuffer().toString();
	HashMap resultMap = mGson.fromJson(result, HashMap.class);
	ArrayList<LinkedHashTreeMap<String, Object>> points = (ArrayList<LinkedHashTreeMap<String, Object>>) resultMap.get("Points");
	Double totalTaskPoint = new Integer(STORY_COUNT * TASK_COUNT * TASK_EST).doubleValue();
	// 算出每一天ideal point的遞減值
	Double periodPoint = totalTaskPoint / (points.size() - 1);
	assertEquals(true, resultMap.get("success"));
	for (int i = 0; i < points.size(); i++) {
		assertEquals(formatter.format(idealPointArray[i]), points.get(i).get("Date"));
		assertEquals(totalTaskPoint - periodPoint * i, points.get(i).get("IdealPoint"));
		// 只有第一天有real point其他因為時間尚未到,所以不會有real point
		if (i == 0) {
			assertEquals(totalTaskPoint, points.get(i).get("RealPoint"));
		} else {
			assertEquals("null", points.get(i).get("RealPoint"));
		}
	}
}
 
Example 9
/**
 * 測試Story的burndown chart當有story拉到done時,資料是否正確
 */
public void testGetSprintBurndownChartData_Task_2() throws Exception {
	final int STORY_COUNT = 2, TASK_COUNT = 2, STORY_EST = 5, TASK_EST = 5;
	// Sprint加入2個Story
	AddStoryToSprint ASTS = new AddStoryToSprint(STORY_COUNT, STORY_EST, mCS, mCP, CreateProductBacklog.COLUMN_TYPE_EST);
	ASTS.exe();

	// 每個Story加入2個task
	AddTaskToStory ATTS = new AddTaskToStory(TASK_COUNT, TASK_EST, ASTS, mCP);
	ATTS.exe();

	// 拿出sprint的每一天日期
	SprintBacklogLogic sprintBacklogLogic = new SprintBacklogLogic(mProject, mCS.getSprintsId().get(0));
	SprintBacklogMapper SprintBacklogMapper = sprintBacklogLogic.getSprintBacklogMapper();
	TaskBoard taskBoard = new TaskBoard(sprintBacklogLogic, SprintBacklogMapper);
	LinkedHashMap<Date, Double> ideal = taskBoard.getStoryIdealPointMap();
	DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
	Object[] idealPointArray = ideal.keySet().toArray();
	// 將task拉到done
	sprintBacklogLogic.closeTask(ATTS.getTasksId().get(0), ATTS.getTasks().get(0).getName(), "", 0, "");

	// ================ set request info ========================
	request.setHeader("Referer", "?PID=" + mProject.getName());
	addRequestParameter("SprintID", String.valueOf(mCS.getSprintsId().get(0)));
	addRequestParameter("Type", "task");

	// ================ set session info ========================s
	request.getSession().setAttribute("UserSession", mConfig.getUserSession());

	// ================ 執行 action ======================
	actionPerform();

	// ================ assert ======================
	verifyNoActionErrors();
	verifyNoActionMessages();
	String result = response.getWriterBuffer().toString();
	HashMap resultMap = mGson.fromJson(result, HashMap.class);
	ArrayList<LinkedHashTreeMap<String, Object>> points = (ArrayList<LinkedHashTreeMap<String, Object>>) resultMap.get("Points");
	assertEquals(true, resultMap.get("success"));
	// 由於done了一個task因此減掉一個task的est
	Double totalTaskPoint = new Integer(STORY_COUNT * TASK_COUNT * TASK_EST).doubleValue() - TASK_EST;
	Double periodPoint = totalTaskPoint / (points.size() - 1);
	for (int i = 0; i < points.size(); i++) {
		assertEquals(formatter.format(idealPointArray[i]), points.get(i).get("Date"));
		assertEquals(totalTaskPoint - periodPoint * i, points.get(i).get("IdealPoint"));
		if (i == 0) {
			assertEquals(totalTaskPoint, points.get(i).get("RealPoint"));
		} else {
			assertEquals("null", points.get(i).get("RealPoint"));
		}
	}
}