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

Rename system.* to system_* in a some files #2330

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions actions/actions_whitebox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (s *ActionSuite) TestActionExecution() {
})
require.NoError(t, err)
require.Len(t, changes, 0)
require.Equal(t, workitem.SystemStateOpen, afterActionWI.(workitem.WorkItem).Fields["system.state"])
require.Equal(t, workitem.SystemStateOpen, afterActionWI.(workitem.WorkItem).Fields["system_state"])
})

s.T().Run("unknown rule", func(t *testing.T) {
Expand All @@ -171,7 +171,7 @@ func (s *ActionSuite) TestActionExecution() {
require.NoError(t, err)
// Intentionally not using a constant here!
afterActionWI, changes, err := ExecuteActionsByChangeset(s.Ctx, s.GormDB, userID, newVersion, contextChanges, map[string]string{
"FieldSet": "{ \"system.state\": \"resolved\" }",
"FieldSet": "{ \"system_state\": \"resolved\" }",
})
require.NoError(t, err)
require.Len(t, changes, 1)
Expand Down
8 changes: 4 additions & 4 deletions actions/rules/action_field_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (s *ActionFieldSetSuite) TestActionExecution() {
}
var convertChanges change.Set
// Not using constants here intentionally.
afterActionWI, convertChanges, err := action.OnChange(newVersion, contextChanges, "{ \"system.state\": \"resolved\" }", &convertChanges)
afterActionWI, convertChanges, err := action.OnChange(newVersion, contextChanges, "{ \"system_state\": \"resolved\" }", &convertChanges)
require.NoError(t, err)
require.Len(t, convertChanges, 1)
require.Equal(t, workitem.SystemState, convertChanges[0].AttributeName)
Expand All @@ -79,15 +79,15 @@ func (s *ActionFieldSetSuite) TestActionExecution() {
}
var convertChanges change.Set
// Not using constants here intentionally.
afterActionWI, convertChanges, err := action.OnChange(newVersion, contextChanges, "{ \"system.state\": \"resolved\" }", &convertChanges)
afterActionWI, convertChanges, err := action.OnChange(newVersion, contextChanges, "{ \"system_state\": \"resolved\" }", &convertChanges)
require.NoError(t, err)
require.Len(t, convertChanges, 1)
require.Equal(t, workitem.SystemState, convertChanges[0].AttributeName)
require.Equal(t, workitem.SystemStateOpen, convertChanges[0].OldValue)
require.Equal(t, workitem.SystemStateResolved, convertChanges[0].NewValue)
require.Equal(t, workitem.SystemStateResolved, afterActionWI.(workitem.WorkItem).Fields[workitem.SystemState])
// doing another change, the convertChange needs to stack.
afterActionWI, convertChanges, err = action.OnChange(afterActionWI, change.Set{}, "{ \"system.state\": \"new\" }", &convertChanges)
afterActionWI, convertChanges, err = action.OnChange(afterActionWI, change.Set{}, "{ \"system_state\": \"new\" }", &convertChanges)
require.NoError(t, err)
require.Len(t, convertChanges, 2)
require.Equal(t, workitem.SystemState, convertChanges[0].AttributeName)
Expand All @@ -112,7 +112,7 @@ func (s *ActionFieldSetSuite) TestActionExecution() {
UserID: &fxt.Identities[0].ID,
}
var convertChanges change.Set
_, _, err = action.OnChange(newVersion, contextChanges, "{ \"system.notavailable\": \"updatedState\" }", &convertChanges)
_, _, err = action.OnChange(newVersion, contextChanges, "{ \"system_notavailable\": \"updatedState\" }", &convertChanges)
require.NotNil(t, err)
})

Expand Down
4 changes: 2 additions & 2 deletions codebase/codebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ func (c *Content) IsRepoValidURL() bool {
// Repository value is mandatory
func (c *Content) IsValid() error {
if c.Repository == "" {
return errors.NewBadParameterError("system.codebase", RepositoryKey+" is mandatory")
return errors.NewBadParameterError("system_codebase", RepositoryKey+" is mandatory")
}
if c.IsRepoValidURL() == false {
return errors.NewBadParameterError("system.codebase", RepositoryKey+" is not valid git url")
return errors.NewBadParameterError("system_codebase", RepositoryKey+" is not valid git url")
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion controller/planner_backlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (c *PlannerBacklogController) List(ctx *app.ListPlannerBacklogContext) erro
return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("could not parse filter", err))
}
if ctx.FilterAssignee != nil {
exp = criteria.And(exp, criteria.Equals(criteria.Field("system.assignees"), criteria.Literal([]string{*ctx.FilterAssignee})))
exp = criteria.And(exp, criteria.Equals(criteria.Field("system_assignees"), criteria.Literal([]string{*ctx.FilterAssignee})))
}
if ctx.FilterWorkitemtype != nil {
exp = criteria.And(exp, criteria.Equals(criteria.Field("Type"), criteria.Literal([]uuid.UUID{*ctx.FilterWorkitemtype})))
Expand Down
2 changes: 1 addition & 1 deletion controller/workitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func ConvertJSONAPIToWorkItem(ctx context.Context, method string, appl applicati
if description, ok := target.Fields[workitem.SystemDescription].(rendering.MarkupContent); ok {
// verify the description markup
if !rendering.IsMarkupSupported(description.Markup) {
return errors.NewBadParameterError("data.relationships.attributes[system.description].markup", description.Markup)
return errors.NewBadParameterError("data.relationships.attributes[system_description].markup", description.Markup)
}
}
return nil
Expand Down
20 changes: 10 additions & 10 deletions controller/workitem_blackbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,15 +576,15 @@ func (s *WorkItemSuite) TestListByFields() {
payload.Data.Attributes[workitem.SystemState] = workitem.SystemStateClosed
test.CreateWorkitemsCreated(s.T(), s.svc.Context, s.svc, s.workitemsCtrl, *payload.Data.Relationships.Space.Data.ID, &payload)
// when
filter := "{\"system.title\":\"run integration test\"}"
filter := "{\"system_title\":\"run integration test\"}"
offset := "0"
limit := 1
_, result := test.ListWorkitemsOK(s.T(), nil, nil, s.workitemsCtrl, *payload.Data.Relationships.Space.Data.ID, &filter, nil, nil, nil, nil, nil, nil, nil, &limit, &offset, nil, nil, nil)
// then
require.NotNil(s.T(), result)
require.Equal(s.T(), 1, len(result.Data))
// when
filter = fmt.Sprintf("{\"system.creator\":%q}", s.testIdentity.ID.String())
filter = fmt.Sprintf("{\"system_creator\":%q}", s.testIdentity.ID.String())
// then
_, result = test.ListWorkitemsOK(s.T(), nil, nil, s.workitemsCtrl, *payload.Data.Relationships.Space.Data.ID, &filter, nil, nil, nil, nil, nil, nil, nil, &limit, &offset, nil, nil, nil)
require.NotNil(s.T(), result)
Expand All @@ -604,9 +604,9 @@ func getWorkItemTestDataFunc(config configuration.Registry) func(t *testing.T) [
"data": {
"type": "workitems"
"attributes": {
"system.state": "new",
"system.title": "My special story",
"system.description": "description"
"system_state": "new",
"system_title": "My special story",
"system_description": "description"
}
}
}`))
Expand Down Expand Up @@ -919,7 +919,7 @@ func (s *WorkItem2Suite) SetupTest() {
// ========== Actual Test functions ==========
func (s *WorkItem2Suite) TestWI2UpdateOnlyState() {
s.minimumPayload.Data.Attributes[workitem.SystemTitle] = "Test title"
s.minimumPayload.Data.Attributes["system.state"] = "invalid_value"
s.minimumPayload.Data.Attributes["system_state"] = "invalid_value"
test.UpdateWorkitemBadRequest(s.T(), s.svc.Context, s.svc, s.workitemCtrl, *s.wi.ID, s.minimumPayload)
newStateValue := "closed"
s.minimumPayload.Data.Attributes[workitem.SystemState] = newStateValue
Expand Down Expand Up @@ -1854,7 +1854,7 @@ func (s *WorkItem2Suite) TestListOrder() {

t.Run("by created descending", func(t *testing.T) {
// when
exp := ptr.String(`{"system.state": "open"}`)
exp := ptr.String(`{"system_state": "open"}`)
sort := ptr.String("-created")
_, actualWIs := test.ListWorkitemsOK(s.T(), s.svc.Context, s.svc, s.workitemsCtrl, fxt.Spaces[0].ID, exp, nil, nil, nil, nil, nil, nil, nil, nil, nil, sort, nil, nil)
// then
Expand Down Expand Up @@ -1882,7 +1882,7 @@ func (s *WorkItem2Suite) TestListOrder() {
require.Empty(t, toBeFound, "failed to find all work items: %+s", toBeFound)
})
t.Run("by created ascending", func(t *testing.T) {
exp := ptr.String(`{"system.state": "open"}`)
exp := ptr.String(`{"system_state": "open"}`)
sort := ptr.String("created")
_, actualWIs := test.ListWorkitemsOK(s.T(), s.svc.Context, s.svc, s.workitemsCtrl, fxt.Spaces[0].ID, exp, nil, nil, nil, nil, nil, nil, nil, nil, nil, sort, nil, nil)
// then
Expand Down Expand Up @@ -1927,7 +1927,7 @@ func (s *WorkItem2Suite) TestListOrder() {
test.UpdateWorkitemOK(s.T(), s.svc.Context, s.svc, s.workitemCtrl, fxt.WorkItems[v].ID, &payload)
}

exp := ptr.String(`{"system.state": "resolved"}`)
exp := ptr.String(`{"system_state": "resolved"}`)
sort := ptr.String("-updated")
_, actualWIs := test.ListWorkitemsOK(s.T(), s.svc.Context, s.svc, s.workitemsCtrl, fxt.Spaces[0].ID, exp, nil, nil, nil, nil, nil, nil, nil, nil, nil, sort, nil, nil)
// then
Expand Down Expand Up @@ -1971,7 +1971,7 @@ func (s *WorkItem2Suite) TestListOrder() {
test.UpdateWorkitemOK(s.T(), s.svc.Context, s.svc, s.workitemCtrl, fxt.WorkItems[v].ID, &payload)
}

exp := ptr.String(`{"system.state": "resolved"}`)
exp := ptr.String(`{"system_state": "resolved"}`)
sort := ptr.String("updated")
_, actualWIs := test.ListWorkitemsOK(s.T(), s.svc.Context, s.svc, s.workitemsCtrl, fxt.Spaces[0].ID, exp, nil, nil, nil, nil, nil, nil, nil, nil, nil, sort, nil, nil)
// then
Expand Down
4 changes: 2 additions & 2 deletions controller/workitems.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ func (c *WorkitemsController) List(ctx *app.ListWorkitemsContext) error {
}
if ctx.FilterAssignee != nil {
if *ctx.FilterAssignee == none {
exp = criteria.And(exp, criteria.IsNull("system.assignees"))
exp = criteria.And(exp, criteria.IsNull("system_assignees"))
additionalQuery = append(additionalQuery, "filter[assignee]=none")

} else {
exp = criteria.And(exp, criteria.Equals(criteria.Field("system.assignees"), criteria.Literal([]string{*ctx.FilterAssignee})))
exp = criteria.And(exp, criteria.Equals(criteria.Field("system_assignees"), criteria.Literal([]string{*ctx.FilterAssignee})))
additionalQuery = append(additionalQuery, "filter[assignee]="+*ctx.FilterAssignee)
}
}
Expand Down
4 changes: 2 additions & 2 deletions design/user_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
var CreateWorkItemPayload = a.Type("CreateWorkItemPayload", func() {
a.Attribute("type", d.UUID, "ID of the work item type of the newly created work item")
a.Attribute("fields", a.HashOf(d.String, d.Any), "The field values, must conform to the type", func() {
a.Example(map[string]interface{}{"system.creator": "user-ref", "system.state": "new", "system.title": "Example story"})
a.Example(map[string]interface{}{"system_creator": "user-ref", "system_state": "new", "system_title": "Example story"})
a.MinLength(1)
})
a.Required("type", "fields")
Expand All @@ -21,7 +21,7 @@ var CreateWorkItemPayload = a.Type("CreateWorkItemPayload", func() {
var UpdateWorkItemPayload = a.Type("UpdateWorkItemPayload", func() {
a.Attribute("type", d.UUID, "ID of the work item type")
a.Attribute("fields", a.HashOf(d.String, d.Any), "The field values, must conform to the type", func() {
a.Example(map[string]interface{}{"system.creator": "user-ref", "system.state": "new", "system.title": "Example story"})
a.Example(map[string]interface{}{"system_creator": "user-ref", "system_state": "new", "system_title": "Example story"})
a.MinLength(1)
})
a.Attribute("version", d.Integer, "Version for optimistic concurrency control", func() {
Expand Down
2 changes: 1 addition & 1 deletion design/work_item_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var eventAttributes = a.Type("EventAttributes", func() {
a.Example("2016-11-29T23:18:14Z")
})
a.Attribute("name", d.String, "The name of the event occured", func() {
a.Example("system.title")
a.Example("system_title")
})
a.Attribute("oldValue", d.Any, "The user who was assigned to (or unassigned from). Only for 'assigned' and 'unassigned' events.", func() {
a.Example("813a456e-1c8a-48df-ac15-84065ee039f7")
Expand Down
4 changes: 2 additions & 2 deletions design/workitems.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var workItem = a.Type("WorkItem", func() {
a.Example("abcd1234-1234-5678-cafe-0123456789ab")
})
a.Attribute("attributes", a.HashOf(d.String, d.Any), func() {
a.Example(map[string]interface{}{"version": "1", "system.state": "new", "system.title": "Example story"})
a.Example(map[string]interface{}{"version": "1", "system_state": "new", "system_title": "Example story"})
})
a.Attribute("relationships", workItemRelationships)
a.Attribute("links", genericLinksForWorkItem)
Expand All @@ -35,7 +35,7 @@ var workItem = a.Type("WorkItem", func() {
var workItemRelationships = a.Type("WorkItemRelationships", func() {
a.Attribute("assignees", relationGenericList, "This defines assignees of the Work Item")
a.Attribute("labels", relationGenericList, "List of labels attached to the Work Item")
a.Attribute("system.boardcolumns", relationGenericList, "List of board columns this Work Item is attached to")
a.Attribute("system_boardcolumns", relationGenericList, "List of board columns this Work Item is attached to")
a.Attribute("creator", relationGeneric, "This defines creator of the Work Item")
a.Attribute("baseType", relationBaseType, "This defines type of Work Item")
a.Attribute("comments", relationGeneric, "This defines comments on the Work Item")
Expand Down
2 changes: 1 addition & 1 deletion design/workitemtype.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var workItemTypeAttributes = a.Type("WorkItemTypeAttributes", func() {
a.Attribute("can-construct", d.Boolean, "Whether or not this work item type is supposed to be used for creating work items directly.")
a.Attribute("fields", a.HashOf(d.String, fieldDefinition), "Definitions of fields in this work item type", func() {
a.Example(map[string]interface{}{
"system.administrator": map[string]interface{}{
"system_administrator": map[string]interface{}{
"type": map[string]interface{}{
"kind": "string",
},
Expand Down
18 changes: 9 additions & 9 deletions docs/board_view.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ The response to `/workitems` and `/workitems/:id` is updated to contain the posi
"data": [
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.title":"Some Work Item",
"system_created_at": "0001-01-01T00:00:00Z",
"system_title":"Some Work Item",
# [...]
},
relationships: {
Expand All @@ -111,9 +111,9 @@ The meta-state is not directly connected to the board/column definitions, but to
"data": [
{
"attributes": {
"system.created_at": "0001-01-01T00:00:00Z",
"system.title": "Some Work Item",
"system.metastate": "mInprogress",
"system_created_at": "0001-01-01T00:00:00Z",
"system_title": "Some Work Item",
"system_metastate": "mInprogress",
# [...]
},
# [...]
Expand Down Expand Up @@ -150,7 +150,7 @@ The above only describes the schema of the board positions and the meta-state va

### Update the Position of Work Items on a Board

When a Work Item is moved on a board by the user, a rule/action is executed on the WIT side on update of the `boardcolumns` relationship. Clients are expected to send a `PATCH` request with the updated list of `boardcolumns` to `/workitems/:id`. *The response of the `PATCH` request contains an updated Work Item that may contain updated attribute and/or relationship values* (for example, an updated `system.state` attribute). The client is expected to update the local Work Item data from that response.
When a Work Item is moved on a board by the user, a rule/action is executed on the WIT side on update of the `boardcolumns` relationship. Clients are expected to send a `PATCH` request with the updated list of `boardcolumns` to `/workitems/:id`. *The response of the `PATCH` request contains an updated Work Item that may contain updated attribute and/or relationship values* (for example, an updated `system_state` attribute). The client is expected to update the local Work Item data from that response.

The rule/action being executed on the WIT side is defined by `transRuleID` and `transRuleArguments` values in the board definition (see above). If a card is moved on the board, that rule/action get executed and calculate the updates necessary to the Work Item.

Expand Down Expand Up @@ -266,7 +266,7 @@ CREATE TABLE boardcolumns (
The meta-state is stored and covered by a new Work Item Type attribute that provides the mapping by using the ordered nature of the enum definitions in the space template. The new attribute is added to the generalized WIT definition so it is inherited by all existing WITs in all templates:

```yaml
"system.metastate":
"system_metastate":
label: Meta-State
description: The meta-state of the work item
read_only: yes
Expand All @@ -279,7 +279,7 @@ The meta-state is stored and covered by a new Work Item Type attribute that prov
# This will allow other WITs to overwrite the values of the state.
rewritable_values: yes
# the sequence of the values need to match the sequence of the
# system.state attributes. This encapsulates the mapping.
# system_state attributes. This encapsulates the mapping.
values:
- mNew
- mOpen
Expand All @@ -288,4 +288,4 @@ The meta-state is stored and covered by a new Work Item Type attribute that prov
- mClosed
```

The implementation needs to get the set of `system.state` values and the set of the `system.metastate` values to get the mapping from state to meta-state. The meta-state will be added to the Work Item JSONAPI model response like every other attribute (see above).
The implementation needs to get the set of `system_state` values and the set of the `system_metastate` values to get the mapping from state to meta-state. The meta-state will be added to the Work Item JSONAPI model response like every other attribute (see above).
14 changes: 7 additions & 7 deletions examples/workitemtype.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The following should fail as nothing is there (yet):
Should create 1 WIT with `name=Epic`:

----
./bin/wit-cli create workitemtype --key "GENERATED_TOKEN" --payload '{"extendedTypeName":null,"fields":{"system.owner":{"type":{"kind":"user"},"required":true},"system.state":{"type":{"kind":"string"},"required":false}},"name":"Epic"}' -H localhost:8080 --pp
./bin/wit-cli create workitemtype --key "GENERATED_TOKEN" --payload '{"extendedTypeName":null,"fields":{"system_owner":{"type":{"kind":"user"},"required":true},"system_state":{"type":{"kind":"string"},"required":false}},"name":"Epic"}' -H localhost:8080 --pp
----

== Show newly created "Epic"
Expand All @@ -33,7 +33,7 @@ Should show you newly created item type:
Create another item type:

----
./bin/wit-cli create workitemtype --key "GENERATED_TOKEN" --payload '{"extendedTypeName":null,"fields":{"system.owner":{"type":{"kind":"user"},"required":true},"system.duration":{"type":{"kind":"integer"},"required":false}},"name":"Issue"}' -H localhost:8080 --pp
./bin/wit-cli create workitemtype --key "GENERATED_TOKEN" --payload '{"extendedTypeName":null,"fields":{"system_owner":{"type":{"kind":"user"},"required":true},"system_duration":{"type":{"kind":"integer"},"required":false}},"name":"Issue"}' -H localhost:8080 --pp
----

Retrieve newly created `Issue` work item type:
Expand All @@ -42,20 +42,20 @@ Retrieve newly created `Issue` work item type:
./bin/wit-cli show workitemtype --name "Issue" -H localhost:8080 --pp
----

Should fail - create item type based on pre-existing item type because `system.state` does not match to parent item type:
Should fail - create item type based on pre-existing item type because `system_state` does not match to parent item type:

(The `system.state` must not be of type `float` but of type `string`.)
(The `system_state` must not be of type `float` but of type `string`.)

----
./bin/wit-cli create workitemtype --key "GENERATED_TOKEN" --payload '{"extendedTypeName":"Epic","fields":{"system.owner":{"type":{"kind":"user"},"required":true},"system.state":{"type":{"kind":"float"},"required":false}},"name":"anotherEpic"}' -H localhost:8080 --pp
./bin/wit-cli create workitemtype --key "GENERATED_TOKEN" --payload '{"extendedTypeName":"Epic","fields":{"system_owner":{"type":{"kind":"user"},"required":true},"system_state":{"type":{"kind":"float"},"required":false}},"name":"anotherEpic"}' -H localhost:8080 --pp
----

Should create item type based on pre-existing item type:

(Now `system.state` has the correct type of `string`.)
(Now `system_state` has the correct type of `string`.)

----
./bin/wit-cli create workitemtype --key "GENERATED_TOKEN" --payload '{"extendedTypeName":"Epic","fields":{"system.owner":{"type":{"kind":"user"},"required":true},"system.state":{"type":{"kind":"string"},"required":false}},"name":"anotherEpic"}' -H localhost:8080 --pp
./bin/wit-cli create workitemtype --key "GENERATED_TOKEN" --payload '{"extendedTypeName":"Epic","fields":{"system_owner":{"type":{"kind":"user"},"required":true},"system_state":{"type":{"kind":"string"},"required":false}},"name":"anotherEpic"}' -H localhost:8080 --pp
----

== List all work item types that we created
Expand Down
Loading