func (h *Handler) authenticationGetExercisesSettings(w http.ResponseWriter, r *http.Request, exercise *sitrep.ExerciseByIdentifier) {
	settings, err := models.FindOrInitSettingsForExercise(h.Cassandra, exercise.Id)
	if err != nil {
		httpError(w, "An unexpected error occured, while fetching your data!", false, http.StatusInternalServerError)
		return
	}
	w.Header().Add("content-type", "application/json")
	w.Write(MarshalJSON(settings, false))
}
func Test_Exercise_Settings_Init(t *testing.T) {
	user := mockUser()
	initUser(user)
	exercise := mockExercise()
	initExercise(exercise)

	_, err := models.FindOrInitSettingsForExercise(dbConn(), exercise.Id)
	if err != nil {
		t.Fatalf("Settings fetch failed")
	}

}
func Test_Exercise_Settings_Successful(t *testing.T) {
	user := mockUser()
	initUser(user)
	exercise := mockExercise()
	initExercise(exercise)

	settings, err := models.FindOrInitSettingsForExercise(dbConn(), exercise.Id)
	if err != nil {
		t.Fatalf("Settings fetch failed")
	}

	if settings["backgroundColorMenuBar"] != "#ccc" {
		t.Fatalf("Settings check failed! %v", settings)
	}

}
func Test_Exercise_Settings_Update(t *testing.T) {
	user := mockUser()
	initUser(user)
	exercise := mockExercise()
	initExercise(exercise)
	defaultSettings := map[string]string{
		"backgroundColorMenuBar": "#ccc",
		"fontColorMenuBar":       "#555",
		"newsStationEnabled":     "true",
		"twitterEnabled":         "true",
		"facebookEnabled":        "false",
		"youtubeEnabled":         "false",
		"usaidEnabled":           "false",
		"dosEnabled":             "true",
		"contactEnabled":         "true",
		"contactDestination":     "*****@*****.**",
		"arcgisMainMapLink":      "",
		"arcgisEmbed":            "true",
		"key":                    "value",
	}
	settings, err := models.UpdateExerciseSetting(dbConn(), exercise.Id, defaultSettings)
	if err != nil {
		t.Fatalf("Settings update failed")
	}

	if settings["key"] != "value" {
		t.Fatalf("Settings check failed! %v", settings)
	}

	settings2, err := models.FindOrInitSettingsForExercise(dbConn(), exercise.Id)
	if err != nil {
		t.Fatalf("Settings fetch failed")
	}
	if settings2["key"] != "value" {
		t.Fatalf("Settings check failed! %v", settings2)
	}

}