mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
Merged 2.0.0-m3
This commit is contained in:
@@ -104,7 +104,7 @@ public final class DiffCommandBuilder
|
|||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public DiffCommandBuilder retriveContent(OutputStream outputStream) throws IOException, RevisionNotFoundException {
|
public DiffCommandBuilder retrieveContent(OutputStream outputStream) throws IOException, RevisionNotFoundException {
|
||||||
getDiffResult(outputStream);
|
getDiffResult(outputStream);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import GroupForm from "../components/GroupForm";
|
import GroupForm from "../components/GroupForm";
|
||||||
import { modifyGroup, fetchGroup } from "../modules/groups";
|
import { modifyGroup } from "../modules/groups";
|
||||||
import type { History } from "history";
|
import type { History } from "history";
|
||||||
import { withRouter } from "react-router-dom";
|
import { withRouter } from "react-router-dom";
|
||||||
import type { Group } from "@scm-manager/ui-types";
|
import type { Group } from "@scm-manager/ui-types";
|
||||||
@@ -12,7 +12,6 @@ import { ErrorNotification } from "@scm-manager/ui-components";
|
|||||||
type Props = {
|
type Props = {
|
||||||
group: Group,
|
group: Group,
|
||||||
modifyGroup: (group: Group, callback?: () => void) => void,
|
modifyGroup: (group: Group, callback?: () => void) => void,
|
||||||
fetchGroup: (name: string) => void,
|
|
||||||
history: History,
|
history: History,
|
||||||
loading?: boolean,
|
loading?: boolean,
|
||||||
error: Error
|
error: Error
|
||||||
@@ -20,7 +19,6 @@ type Props = {
|
|||||||
|
|
||||||
class EditGroup extends React.Component<Props> {
|
class EditGroup extends React.Component<Props> {
|
||||||
groupModified = (group: Group) => () => {
|
groupModified = (group: Group) => () => {
|
||||||
this.props.fetchGroup(group.name);
|
|
||||||
this.props.history.push(`/group/${group.name}`);
|
this.props.history.push(`/group/${group.name}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -58,9 +56,6 @@ const mapDispatchToProps = dispatch => {
|
|||||||
return {
|
return {
|
||||||
modifyGroup: (group: Group, callback?: () => void) => {
|
modifyGroup: (group: Group, callback?: () => void) => {
|
||||||
dispatch(modifyGroup(group, callback));
|
dispatch(modifyGroup(group, callback));
|
||||||
},
|
|
||||||
fetchGroup: (name: string) => {
|
|
||||||
dispatch(fetchGroup(name));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import type { Group } from "@scm-manager/ui-types";
|
|||||||
import type { History } from "history";
|
import type { History } from "history";
|
||||||
import {
|
import {
|
||||||
deleteGroup,
|
deleteGroup,
|
||||||
fetchGroup,
|
fetchGroupByName,
|
||||||
getGroupByName,
|
getGroupByName,
|
||||||
isFetchGroupPending,
|
isFetchGroupPending,
|
||||||
getFetchGroupFailure,
|
getFetchGroupFailure,
|
||||||
@@ -37,7 +37,7 @@ type Props = {
|
|||||||
|
|
||||||
// dispatcher functions
|
// dispatcher functions
|
||||||
deleteGroup: (group: Group, callback?: () => void) => void,
|
deleteGroup: (group: Group, callback?: () => void) => void,
|
||||||
fetchGroup: (string, string) => void,
|
fetchGroupByName: (string, string) => void,
|
||||||
|
|
||||||
// context objects
|
// context objects
|
||||||
t: string => string,
|
t: string => string,
|
||||||
@@ -47,7 +47,7 @@ type Props = {
|
|||||||
|
|
||||||
class SingleGroup extends React.Component<Props> {
|
class SingleGroup extends React.Component<Props> {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.fetchGroup(this.props.groupLink, this.props.name);
|
this.props.fetchGroupByName(this.props.groupLink, this.props.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
stripEndingSlash = (url: string) => {
|
stripEndingSlash = (url: string) => {
|
||||||
@@ -147,8 +147,8 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
fetchGroup: (link: string, name: string) => {
|
fetchGroupByName: (link: string, name: string) => {
|
||||||
dispatch(fetchGroup(link, name));
|
dispatch(fetchGroupByName(link, name));
|
||||||
},
|
},
|
||||||
deleteGroup: (group: Group, callback?: () => void) => {
|
deleteGroup: (group: Group, callback?: () => void) => {
|
||||||
dispatch(deleteGroup(group, callback));
|
dispatch(deleteGroup(group, callback));
|
||||||
|
|||||||
@@ -84,12 +84,20 @@ export function fetchGroupsFailure(url: string, error: Error): Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//fetch group
|
//fetch group
|
||||||
export function fetchGroup(link: string, name: string) {
|
export function fetchGroupByLink(group: Group) {
|
||||||
|
return fetchGroup(group._links.self.href, group.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchGroupByName(link: string, name: string) {
|
||||||
const groupUrl = link.endsWith("/") ? link + name : link + "/" + name;
|
const groupUrl = link.endsWith("/") ? link + name : link + "/" + name;
|
||||||
|
return fetchGroup(groupUrl, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchGroup(link: string, name: string) {
|
||||||
return function(dispatch: any) {
|
return function(dispatch: any) {
|
||||||
dispatch(fetchGroupPending(name));
|
dispatch(fetchGroupPending(name));
|
||||||
return apiClient
|
return apiClient
|
||||||
.get(groupUrl)
|
.get(link)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
return response.json();
|
return response.json();
|
||||||
})
|
})
|
||||||
@@ -189,6 +197,9 @@ export function modifyGroup(group: Group, callback?: () => void) {
|
|||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.then(() => {
|
||||||
|
dispatch(fetchGroupByLink(group));
|
||||||
|
})
|
||||||
.catch(cause => {
|
.catch(cause => {
|
||||||
dispatch(
|
dispatch(
|
||||||
modifyGroupFailure(
|
modifyGroupFailure(
|
||||||
@@ -361,8 +372,6 @@ function byNamesReducer(state: any = {}, action: any = {}) {
|
|||||||
};
|
};
|
||||||
case FETCH_GROUP_SUCCESS:
|
case FETCH_GROUP_SUCCESS:
|
||||||
return reducerByName(state, action.payload.name, action.payload);
|
return reducerByName(state, action.payload.name, action.payload);
|
||||||
case MODIFY_GROUP_SUCCESS:
|
|
||||||
return reducerByName(state, action.payload.name, action.payload);
|
|
||||||
case DELETE_GROUP_SUCCESS:
|
case DELETE_GROUP_SUCCESS:
|
||||||
const newGroupByNames = deleteGroupInGroupsByNames(
|
const newGroupByNames = deleteGroupInGroupsByNames(
|
||||||
state,
|
state,
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ import reducer, {
|
|||||||
getFetchGroupsFailure,
|
getFetchGroupsFailure,
|
||||||
isFetchGroupsPending,
|
isFetchGroupsPending,
|
||||||
selectListAsCollection,
|
selectListAsCollection,
|
||||||
fetchGroup,
|
fetchGroupByLink,
|
||||||
|
fetchGroupByName,
|
||||||
FETCH_GROUP_PENDING,
|
FETCH_GROUP_PENDING,
|
||||||
FETCH_GROUP_SUCCESS,
|
FETCH_GROUP_SUCCESS,
|
||||||
FETCH_GROUP_FAILURE,
|
FETCH_GROUP_FAILURE,
|
||||||
@@ -46,6 +47,7 @@ import reducer, {
|
|||||||
getCreateGroupLink
|
getCreateGroupLink
|
||||||
} from "./groups";
|
} from "./groups";
|
||||||
const GROUPS_URL = "/api/v2/groups";
|
const GROUPS_URL = "/api/v2/groups";
|
||||||
|
const URL_HUMAN_GROUP = "http://localhost:8081/api/v2/groups/humanGroup";
|
||||||
const URL = "/groups";
|
const URL = "/groups";
|
||||||
|
|
||||||
const error = new Error("You have an error!");
|
const error = new Error("You have an error!");
|
||||||
@@ -59,13 +61,13 @@ const humanGroup = {
|
|||||||
members: ["userZaphod"],
|
members: ["userZaphod"],
|
||||||
_links: {
|
_links: {
|
||||||
self: {
|
self: {
|
||||||
href: "http://localhost:8081/api/v2/groups/humanGroup"
|
href: URL_HUMAN_GROUP
|
||||||
},
|
},
|
||||||
delete: {
|
delete: {
|
||||||
href: "http://localhost:8081/api/v2/groups/humanGroup"
|
href: URL_HUMAN_GROUP
|
||||||
},
|
},
|
||||||
update: {
|
update: {
|
||||||
href: "http://localhost:8081/api/v2/groups/humanGroup"
|
href: URL_HUMAN_GROUP
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_embedded: {
|
_embedded: {
|
||||||
@@ -171,11 +173,37 @@ describe("groups fetch()", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should sucessfully fetch single group", () => {
|
it("should sucessfully fetch single group by name", () => {
|
||||||
fetchMock.getOnce(GROUPS_URL + "/humanGroup", humanGroup);
|
fetchMock.getOnce(GROUPS_URL + "/humanGroup", humanGroup);
|
||||||
|
|
||||||
const store = mockStore({});
|
const store = mockStore({});
|
||||||
return store.dispatch(fetchGroup(URL, "humanGroup")).then(() => {
|
return store.dispatch(fetchGroupByName(URL, "humanGroup")).then(() => {
|
||||||
|
const actions = store.getActions();
|
||||||
|
expect(actions[0].type).toEqual(FETCH_GROUP_PENDING);
|
||||||
|
expect(actions[1].type).toEqual(FETCH_GROUP_SUCCESS);
|
||||||
|
expect(actions[1].payload).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should fail fetching single group by name on HTTP 500", () => {
|
||||||
|
fetchMock.getOnce(GROUPS_URL + "/humanGroup", {
|
||||||
|
status: 500
|
||||||
|
});
|
||||||
|
|
||||||
|
const store = mockStore({});
|
||||||
|
return store.dispatch(fetchGroupByName(URL, "humanGroup")).then(() => {
|
||||||
|
const actions = store.getActions();
|
||||||
|
expect(actions[0].type).toEqual(FETCH_GROUP_PENDING);
|
||||||
|
expect(actions[1].type).toEqual(FETCH_GROUP_FAILURE);
|
||||||
|
expect(actions[1].payload).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should sucessfully fetch single group", () => {
|
||||||
|
fetchMock.getOnce(URL_HUMAN_GROUP, humanGroup);
|
||||||
|
|
||||||
|
const store = mockStore({});
|
||||||
|
return store.dispatch(fetchGroupByLink(humanGroup)).then(() => {
|
||||||
const actions = store.getActions();
|
const actions = store.getActions();
|
||||||
expect(actions[0].type).toEqual(FETCH_GROUP_PENDING);
|
expect(actions[0].type).toEqual(FETCH_GROUP_PENDING);
|
||||||
expect(actions[1].type).toEqual(FETCH_GROUP_SUCCESS);
|
expect(actions[1].type).toEqual(FETCH_GROUP_SUCCESS);
|
||||||
@@ -184,12 +212,12 @@ describe("groups fetch()", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should fail fetching single group on HTTP 500", () => {
|
it("should fail fetching single group on HTTP 500", () => {
|
||||||
fetchMock.getOnce(GROUPS_URL + "/humanGroup", {
|
fetchMock.getOnce(URL_HUMAN_GROUP, {
|
||||||
status: 500
|
status: 500
|
||||||
});
|
});
|
||||||
|
|
||||||
const store = mockStore({});
|
const store = mockStore({});
|
||||||
return store.dispatch(fetchGroup(URL, "humanGroup")).then(() => {
|
return store.dispatch(fetchGroupByLink(humanGroup)).then(() => {
|
||||||
const actions = store.getActions();
|
const actions = store.getActions();
|
||||||
expect(actions[0].type).toEqual(FETCH_GROUP_PENDING);
|
expect(actions[0].type).toEqual(FETCH_GROUP_PENDING);
|
||||||
expect(actions[1].type).toEqual(FETCH_GROUP_FAILURE);
|
expect(actions[1].type).toEqual(FETCH_GROUP_FAILURE);
|
||||||
@@ -244,9 +272,10 @@ describe("groups fetch()", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should successfully modify group", () => {
|
it("should successfully modify group", () => {
|
||||||
fetchMock.putOnce("http://localhost:8081/api/v2/groups/humanGroup", {
|
fetchMock.putOnce(URL_HUMAN_GROUP, {
|
||||||
status: 204
|
status: 204
|
||||||
});
|
});
|
||||||
|
fetchMock.getOnce(URL_HUMAN_GROUP, humanGroup);
|
||||||
|
|
||||||
const store = mockStore({});
|
const store = mockStore({});
|
||||||
|
|
||||||
@@ -254,14 +283,16 @@ describe("groups fetch()", () => {
|
|||||||
const actions = store.getActions();
|
const actions = store.getActions();
|
||||||
expect(actions[0].type).toEqual(MODIFY_GROUP_PENDING);
|
expect(actions[0].type).toEqual(MODIFY_GROUP_PENDING);
|
||||||
expect(actions[1].type).toEqual(MODIFY_GROUP_SUCCESS);
|
expect(actions[1].type).toEqual(MODIFY_GROUP_SUCCESS);
|
||||||
|
expect(actions[2].type).toEqual(FETCH_GROUP_PENDING);
|
||||||
expect(actions[1].payload).toEqual(humanGroup);
|
expect(actions[1].payload).toEqual(humanGroup);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should call the callback after modifying group", () => {
|
it("should call the callback after modifying group", () => {
|
||||||
fetchMock.putOnce("http://localhost:8081/api/v2/groups/humanGroup", {
|
fetchMock.putOnce(URL_HUMAN_GROUP, {
|
||||||
status: 204
|
status: 204
|
||||||
});
|
});
|
||||||
|
fetchMock.getOnce(URL_HUMAN_GROUP, humanGroup);
|
||||||
|
|
||||||
let called = false;
|
let called = false;
|
||||||
const callback = () => {
|
const callback = () => {
|
||||||
@@ -273,12 +304,13 @@ describe("groups fetch()", () => {
|
|||||||
const actions = store.getActions();
|
const actions = store.getActions();
|
||||||
expect(actions[0].type).toEqual(MODIFY_GROUP_PENDING);
|
expect(actions[0].type).toEqual(MODIFY_GROUP_PENDING);
|
||||||
expect(actions[1].type).toEqual(MODIFY_GROUP_SUCCESS);
|
expect(actions[1].type).toEqual(MODIFY_GROUP_SUCCESS);
|
||||||
|
expect(actions[2].type).toEqual(FETCH_GROUP_PENDING);
|
||||||
expect(called).toBe(true);
|
expect(called).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should fail modifying group on HTTP 500", () => {
|
it("should fail modifying group on HTTP 500", () => {
|
||||||
fetchMock.putOnce("http://localhost:8081/api/v2/groups/humanGroup", {
|
fetchMock.putOnce(URL_HUMAN_GROUP, {
|
||||||
status: 500
|
status: 500
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -293,7 +325,7 @@ describe("groups fetch()", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should delete successfully group humanGroup", () => {
|
it("should delete successfully group humanGroup", () => {
|
||||||
fetchMock.deleteOnce("http://localhost:8081/api/v2/groups/humanGroup", {
|
fetchMock.deleteOnce(URL_HUMAN_GROUP, {
|
||||||
status: 204
|
status: 204
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -308,7 +340,7 @@ describe("groups fetch()", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should call the callback, after successful delete", () => {
|
it("should call the callback, after successful delete", () => {
|
||||||
fetchMock.deleteOnce("http://localhost:8081/api/v2/groups/humanGroup", {
|
fetchMock.deleteOnce(URL_HUMAN_GROUP, {
|
||||||
status: 204
|
status: 204
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -324,7 +356,7 @@ describe("groups fetch()", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should fail to delete group humanGroup", () => {
|
it("should fail to delete group humanGroup", () => {
|
||||||
fetchMock.deleteOnce("http://localhost:8081/api/v2/groups/humanGroup", {
|
fetchMock.deleteOnce(URL_HUMAN_GROUP, {
|
||||||
status: 500
|
status: 500
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import {
|
import {
|
||||||
deleteRepo,
|
deleteRepo,
|
||||||
fetchRepo,
|
fetchRepoByName,
|
||||||
getFetchRepoFailure,
|
getFetchRepoFailure,
|
||||||
getRepository,
|
getRepository,
|
||||||
isFetchRepoPending
|
isFetchRepoPending
|
||||||
@@ -45,7 +45,7 @@ type Props = {
|
|||||||
repoLink: string,
|
repoLink: string,
|
||||||
|
|
||||||
// dispatch functions
|
// dispatch functions
|
||||||
fetchRepo: (link: string, namespace: string, name: string) => void,
|
fetchRepoByName: (link: string, namespace: string, name: string) => void,
|
||||||
deleteRepo: (repository: Repository, () => void) => void,
|
deleteRepo: (repository: Repository, () => void) => void,
|
||||||
|
|
||||||
// context props
|
// context props
|
||||||
@@ -56,9 +56,9 @@ type Props = {
|
|||||||
|
|
||||||
class RepositoryRoot extends React.Component<Props> {
|
class RepositoryRoot extends React.Component<Props> {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { fetchRepo, namespace, name, repoLink } = this.props;
|
const { fetchRepoByName, namespace, name, repoLink } = this.props;
|
||||||
|
|
||||||
fetchRepo(repoLink, namespace, name);
|
fetchRepoByName(repoLink, namespace, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
stripEndingSlash = (url: string) => {
|
stripEndingSlash = (url: string) => {
|
||||||
@@ -222,8 +222,8 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
fetchRepo: (link: string, namespace: string, name: string) => {
|
fetchRepoByName: (link: string, namespace: string, name: string) => {
|
||||||
dispatch(fetchRepo(link, namespace, name));
|
dispatch(fetchRepoByName(link, namespace, name));
|
||||||
},
|
},
|
||||||
deleteRepo: (repository: Repository, callback: () => void) => {
|
deleteRepo: (repository: Repository, callback: () => void) => {
|
||||||
dispatch(deleteRepo(repository, callback));
|
dispatch(deleteRepo(repository, callback));
|
||||||
|
|||||||
@@ -99,13 +99,20 @@ export function fetchReposFailure(err: Error): Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fetch repo
|
// fetch repo
|
||||||
|
export function fetchRepoByLink(repo: Repository) {
|
||||||
|
return fetchRepo(repo._links.self.href, repo.namespace, repo.name);
|
||||||
|
}
|
||||||
|
|
||||||
export function fetchRepo(link: string, namespace: string, name: string) {
|
export function fetchRepoByName(link: string, namespace: string, name: string) {
|
||||||
const repoUrl = link.endsWith("/") ? link : link + "/";
|
const repoUrl = link.endsWith("/") ? link : link + "/";
|
||||||
|
return fetchRepo(`${repoUrl}${namespace}/${name}`, namespace, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchRepo(link: string, namespace: string, name: string) {
|
||||||
return function(dispatch: any) {
|
return function(dispatch: any) {
|
||||||
dispatch(fetchRepoPending(namespace, name));
|
dispatch(fetchRepoPending(namespace, name));
|
||||||
return apiClient
|
return apiClient
|
||||||
.get(`${repoUrl}${namespace}/${name}`)
|
.get(link)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(repository => {
|
.then(repository => {
|
||||||
dispatch(fetchRepoSuccess(repository));
|
dispatch(fetchRepoSuccess(repository));
|
||||||
@@ -213,6 +220,9 @@ export function modifyRepo(repository: Repository, callback?: () => void) {
|
|||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.then(() => {
|
||||||
|
dispatch(fetchRepoByLink(repository));
|
||||||
|
})
|
||||||
.catch(cause => {
|
.catch(cause => {
|
||||||
const error = new Error(`failed to modify repo: ${cause.message}`);
|
const error = new Error(`failed to modify repo: ${cause.message}`);
|
||||||
dispatch(modifyRepoFailure(repository, error));
|
dispatch(modifyRepoFailure(repository, error));
|
||||||
@@ -347,8 +357,6 @@ export default function reducer(
|
|||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case FETCH_REPOS_SUCCESS:
|
case FETCH_REPOS_SUCCESS:
|
||||||
return normalizeByNamespaceAndName(action.payload);
|
return normalizeByNamespaceAndName(action.payload);
|
||||||
case MODIFY_REPO_SUCCESS:
|
|
||||||
return reducerByNames(state, action.payload);
|
|
||||||
case FETCH_REPO_SUCCESS:
|
case FETCH_REPO_SUCCESS:
|
||||||
return reducerByNames(state, action.payload);
|
return reducerByNames(state, action.payload);
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ import reducer, {
|
|||||||
fetchReposByLink,
|
fetchReposByLink,
|
||||||
fetchReposByPage,
|
fetchReposByPage,
|
||||||
FETCH_REPO,
|
FETCH_REPO,
|
||||||
fetchRepo,
|
fetchRepoByLink,
|
||||||
|
fetchRepoByName,
|
||||||
FETCH_REPO_PENDING,
|
FETCH_REPO_PENDING,
|
||||||
FETCH_REPO_SUCCESS,
|
FETCH_REPO_SUCCESS,
|
||||||
FETCH_REPO_FAILURE,
|
FETCH_REPO_FAILURE,
|
||||||
@@ -45,7 +46,6 @@ import reducer, {
|
|||||||
MODIFY_REPO,
|
MODIFY_REPO,
|
||||||
isModifyRepoPending,
|
isModifyRepoPending,
|
||||||
getModifyRepoFailure,
|
getModifyRepoFailure,
|
||||||
modifyRepoSuccess,
|
|
||||||
getPermissionsLink
|
getPermissionsLink
|
||||||
} from "./repos";
|
} from "./repos";
|
||||||
import type { Repository, RepositoryCollection } from "@scm-manager/ui-types";
|
import type { Repository, RepositoryCollection } from "@scm-manager/ui-types";
|
||||||
@@ -323,7 +323,7 @@ describe("repos fetch", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should successfully fetch repo slarti/fjords", () => {
|
it("should successfully fetch repo slarti/fjords by name", () => {
|
||||||
fetchMock.getOnce(REPOS_URL + "/slarti/fjords", slartiFjords);
|
fetchMock.getOnce(REPOS_URL + "/slarti/fjords", slartiFjords);
|
||||||
|
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
@@ -343,18 +343,66 @@ describe("repos fetch", () => {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const store = mockStore({});
|
const store = mockStore({});
|
||||||
return store.dispatch(fetchRepo(URL, "slarti", "fjords")).then(() => {
|
return store.dispatch(fetchRepoByName(URL, "slarti", "fjords")).then(() => {
|
||||||
expect(store.getActions()).toEqual(expectedActions);
|
expect(store.getActions()).toEqual(expectedActions);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should dispatch FETCH_REPO_FAILURE, it the request for slarti/fjords fails", () => {
|
it("should dispatch FETCH_REPO_FAILURE, if the request for slarti/fjords by name fails", () => {
|
||||||
fetchMock.getOnce(REPOS_URL + "/slarti/fjords", {
|
fetchMock.getOnce(REPOS_URL + "/slarti/fjords", {
|
||||||
status: 500
|
status: 500
|
||||||
});
|
});
|
||||||
|
|
||||||
const store = mockStore({});
|
const store = mockStore({});
|
||||||
return store.dispatch(fetchRepo(URL, "slarti", "fjords")).then(() => {
|
return store.dispatch(fetchRepoByName(URL, "slarti", "fjords")).then(() => {
|
||||||
|
const actions = store.getActions();
|
||||||
|
expect(actions[0].type).toEqual(FETCH_REPO_PENDING);
|
||||||
|
expect(actions[1].type).toEqual(FETCH_REPO_FAILURE);
|
||||||
|
expect(actions[1].payload.namespace).toBe("slarti");
|
||||||
|
expect(actions[1].payload.name).toBe("fjords");
|
||||||
|
expect(actions[1].payload.error).toBeDefined();
|
||||||
|
expect(actions[1].itemId).toBe("slarti/fjords");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should successfully fetch repo slarti/fjords", () => {
|
||||||
|
fetchMock.getOnce(
|
||||||
|
"http://localhost:8081/api/v2/repositories/slarti/fjords",
|
||||||
|
slartiFjords
|
||||||
|
);
|
||||||
|
|
||||||
|
const expectedActions = [
|
||||||
|
{
|
||||||
|
type: FETCH_REPO_PENDING,
|
||||||
|
payload: {
|
||||||
|
namespace: "slarti",
|
||||||
|
name: "fjords"
|
||||||
|
},
|
||||||
|
itemId: "slarti/fjords"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: FETCH_REPO_SUCCESS,
|
||||||
|
payload: slartiFjords,
|
||||||
|
itemId: "slarti/fjords"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const store = mockStore({});
|
||||||
|
return store.dispatch(fetchRepoByLink(slartiFjords)).then(() => {
|
||||||
|
expect(store.getActions()).toEqual(expectedActions);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should dispatch FETCH_REPO_FAILURE, it the request for slarti/fjords fails", () => {
|
||||||
|
fetchMock.getOnce(
|
||||||
|
"http://localhost:8081/api/v2/repositories/slarti/fjords",
|
||||||
|
{
|
||||||
|
status: 500
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const store = mockStore({});
|
||||||
|
return store.dispatch(fetchRepoByLink(slartiFjords)).then(() => {
|
||||||
const actions = store.getActions();
|
const actions = store.getActions();
|
||||||
expect(actions[0].type).toEqual(FETCH_REPO_PENDING);
|
expect(actions[0].type).toEqual(FETCH_REPO_PENDING);
|
||||||
expect(actions[1].type).toEqual(FETCH_REPO_FAILURE);
|
expect(actions[1].type).toEqual(FETCH_REPO_FAILURE);
|
||||||
@@ -485,6 +533,12 @@ describe("repos fetch", () => {
|
|||||||
fetchMock.putOnce(slartiFjords._links.update.href, {
|
fetchMock.putOnce(slartiFjords._links.update.href, {
|
||||||
status: 204
|
status: 204
|
||||||
});
|
});
|
||||||
|
fetchMock.getOnce(
|
||||||
|
"http://localhost:8081/api/v2/repositories/slarti/fjords",
|
||||||
|
{
|
||||||
|
status: 500
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
let editedFjords = { ...slartiFjords };
|
let editedFjords = { ...slartiFjords };
|
||||||
editedFjords.description = "coast of africa";
|
editedFjords.description = "coast of africa";
|
||||||
@@ -495,6 +549,7 @@ describe("repos fetch", () => {
|
|||||||
const actions = store.getActions();
|
const actions = store.getActions();
|
||||||
expect(actions[0].type).toEqual(MODIFY_REPO_PENDING);
|
expect(actions[0].type).toEqual(MODIFY_REPO_PENDING);
|
||||||
expect(actions[1].type).toEqual(MODIFY_REPO_SUCCESS);
|
expect(actions[1].type).toEqual(MODIFY_REPO_SUCCESS);
|
||||||
|
expect(actions[2].type).toEqual(FETCH_REPO_PENDING);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -502,6 +557,12 @@ describe("repos fetch", () => {
|
|||||||
fetchMock.putOnce(slartiFjords._links.update.href, {
|
fetchMock.putOnce(slartiFjords._links.update.href, {
|
||||||
status: 204
|
status: 204
|
||||||
});
|
});
|
||||||
|
fetchMock.getOnce(
|
||||||
|
"http://localhost:8081/api/v2/repositories/slarti/fjords",
|
||||||
|
{
|
||||||
|
status: 500
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
let editedFjords = { ...slartiFjords };
|
let editedFjords = { ...slartiFjords };
|
||||||
editedFjords.description = "coast of africa";
|
editedFjords.description = "coast of africa";
|
||||||
@@ -517,6 +578,7 @@ describe("repos fetch", () => {
|
|||||||
const actions = store.getActions();
|
const actions = store.getActions();
|
||||||
expect(actions[0].type).toEqual(MODIFY_REPO_PENDING);
|
expect(actions[0].type).toEqual(MODIFY_REPO_PENDING);
|
||||||
expect(actions[1].type).toEqual(MODIFY_REPO_SUCCESS);
|
expect(actions[1].type).toEqual(MODIFY_REPO_SUCCESS);
|
||||||
|
expect(actions[2].type).toEqual(FETCH_REPO_PENDING);
|
||||||
expect(called).toBe(true);
|
expect(called).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -574,18 +636,6 @@ describe("repos reducer", () => {
|
|||||||
const newState = reducer({}, fetchRepoSuccess(slartiFjords));
|
const newState = reducer({}, fetchRepoSuccess(slartiFjords));
|
||||||
expect(newState.byNames["slarti/fjords"]).toBe(slartiFjords);
|
expect(newState.byNames["slarti/fjords"]).toBe(slartiFjords);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should update reposByNames", () => {
|
|
||||||
const oldState = {
|
|
||||||
byNames: {
|
|
||||||
"slarti/fjords": slartiFjords
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let slartiFjordsEdited = { ...slartiFjords };
|
|
||||||
slartiFjordsEdited.description = "I bless the rains down in Africa";
|
|
||||||
const newState = reducer(oldState, modifyRepoSuccess(slartiFjordsEdited));
|
|
||||||
expect(newState.byNames["slarti/fjords"]).toEqual(slartiFjordsEdited);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("repos selectors", () => {
|
describe("repos selectors", () => {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import EditUser from "./EditUser";
|
|||||||
import type { User } from "@scm-manager/ui-types";
|
import type { User } from "@scm-manager/ui-types";
|
||||||
import type { History } from "history";
|
import type { History } from "history";
|
||||||
import {
|
import {
|
||||||
fetchUser,
|
fetchUserByName,
|
||||||
deleteUser,
|
deleteUser,
|
||||||
getUserByName,
|
getUserByName,
|
||||||
isFetchUserPending,
|
isFetchUserPending,
|
||||||
@@ -42,7 +42,7 @@ type Props = {
|
|||||||
|
|
||||||
// dispatcher functions
|
// dispatcher functions
|
||||||
deleteUser: (user: User, callback?: () => void) => void,
|
deleteUser: (user: User, callback?: () => void) => void,
|
||||||
fetchUser: (string, string) => void,
|
fetchUserByName: (string, string) => void,
|
||||||
|
|
||||||
// context objects
|
// context objects
|
||||||
t: string => string,
|
t: string => string,
|
||||||
@@ -52,7 +52,7 @@ type Props = {
|
|||||||
|
|
||||||
class SingleUser extends React.Component<Props> {
|
class SingleUser extends React.Component<Props> {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.fetchUser(this.props.usersLink, this.props.name);
|
this.props.fetchUserByName(this.props.usersLink, this.props.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
userDeleted = () => {
|
userDeleted = () => {
|
||||||
@@ -151,8 +151,8 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
fetchUser: (link: string, name: string) => {
|
fetchUserByName: (link: string, name: string) => {
|
||||||
dispatch(fetchUser(link, name));
|
dispatch(fetchUserByName(link, name));
|
||||||
},
|
},
|
||||||
deleteUser: (user: User, callback?: () => void) => {
|
deleteUser: (user: User, callback?: () => void) => {
|
||||||
dispatch(deleteUser(user, callback));
|
dispatch(deleteUser(user, callback));
|
||||||
|
|||||||
@@ -87,12 +87,20 @@ export function fetchUsersFailure(url: string, error: Error): Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//fetch user
|
//fetch user
|
||||||
export function fetchUser(link: string, name: string) {
|
export function fetchUserByName(link: string, name: string) {
|
||||||
const userUrl = link.endsWith("/") ? link + name : link + "/" + name;
|
const userUrl = link.endsWith("/") ? link + name : link + "/" + name;
|
||||||
|
return fetchUser(userUrl, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchUserByLink(user: User) {
|
||||||
|
return fetchUser(user._links.self.href, user.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchUser(link: string, name: string) {
|
||||||
return function(dispatch: any) {
|
return function(dispatch: any) {
|
||||||
dispatch(fetchUserPending(name));
|
dispatch(fetchUserPending(name));
|
||||||
return apiClient
|
return apiClient
|
||||||
.get(userUrl)
|
.get(link)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
return response.json();
|
return response.json();
|
||||||
})
|
})
|
||||||
@@ -195,6 +203,9 @@ export function modifyUser(user: User, callback?: () => void) {
|
|||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.then(() => {
|
||||||
|
dispatch(fetchUserByLink(user));
|
||||||
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
dispatch(modifyUserFailure(user, err));
|
dispatch(modifyUserFailure(user, err));
|
||||||
});
|
});
|
||||||
@@ -365,9 +376,6 @@ function byNamesReducer(state: any = {}, action: any = {}) {
|
|||||||
case FETCH_USER_SUCCESS:
|
case FETCH_USER_SUCCESS:
|
||||||
return reducerByName(state, action.payload.name, action.payload);
|
return reducerByName(state, action.payload.name, action.payload);
|
||||||
|
|
||||||
case MODIFY_USER_SUCCESS:
|
|
||||||
return reducerByName(state, action.payload.name, action.payload);
|
|
||||||
|
|
||||||
case DELETE_USER_SUCCESS:
|
case DELETE_USER_SUCCESS:
|
||||||
const newUserByNames = deleteUserInUsersByNames(
|
const newUserByNames = deleteUserInUsersByNames(
|
||||||
state,
|
state,
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ import reducer, {
|
|||||||
FETCH_USERS_FAILURE,
|
FETCH_USERS_FAILURE,
|
||||||
FETCH_USERS_PENDING,
|
FETCH_USERS_PENDING,
|
||||||
FETCH_USERS_SUCCESS,
|
FETCH_USERS_SUCCESS,
|
||||||
fetchUser,
|
fetchUserByLink,
|
||||||
|
fetchUserByName,
|
||||||
fetchUserSuccess,
|
fetchUserSuccess,
|
||||||
getFetchUserFailure,
|
getFetchUserFailure,
|
||||||
fetchUsers,
|
fetchUsers,
|
||||||
@@ -33,7 +34,6 @@ import reducer, {
|
|||||||
MODIFY_USER_PENDING,
|
MODIFY_USER_PENDING,
|
||||||
MODIFY_USER_SUCCESS,
|
MODIFY_USER_SUCCESS,
|
||||||
modifyUser,
|
modifyUser,
|
||||||
modifyUserSuccess,
|
|
||||||
getUsersFromState,
|
getUsersFromState,
|
||||||
FETCH_USERS,
|
FETCH_USERS,
|
||||||
getFetchUsersFailure,
|
getFetchUsersFailure,
|
||||||
@@ -124,6 +124,7 @@ const response = {
|
|||||||
|
|
||||||
const URL = "users";
|
const URL = "users";
|
||||||
const USERS_URL = "/api/v2/users";
|
const USERS_URL = "/api/v2/users";
|
||||||
|
const USER_ZAPHOD_URL = "http://localhost:8081/api/v2/users/zaphod";
|
||||||
|
|
||||||
const error = new Error("KAPUTT");
|
const error = new Error("KAPUTT");
|
||||||
|
|
||||||
@@ -166,11 +167,37 @@ describe("users fetch()", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should sucessfully fetch single user", () => {
|
it("should sucessfully fetch single user by name", () => {
|
||||||
fetchMock.getOnce(USERS_URL + "/zaphod", userZaphod);
|
fetchMock.getOnce(USERS_URL + "/zaphod", userZaphod);
|
||||||
|
|
||||||
const store = mockStore({});
|
const store = mockStore({});
|
||||||
return store.dispatch(fetchUser(URL, "zaphod")).then(() => {
|
return store.dispatch(fetchUserByName(URL, "zaphod")).then(() => {
|
||||||
|
const actions = store.getActions();
|
||||||
|
expect(actions[0].type).toEqual(FETCH_USER_PENDING);
|
||||||
|
expect(actions[1].type).toEqual(FETCH_USER_SUCCESS);
|
||||||
|
expect(actions[1].payload).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should fail fetching single user by name on HTTP 500", () => {
|
||||||
|
fetchMock.getOnce(USERS_URL + "/zaphod", {
|
||||||
|
status: 500
|
||||||
|
});
|
||||||
|
|
||||||
|
const store = mockStore({});
|
||||||
|
return store.dispatch(fetchUserByName(URL, "zaphod")).then(() => {
|
||||||
|
const actions = store.getActions();
|
||||||
|
expect(actions[0].type).toEqual(FETCH_USER_PENDING);
|
||||||
|
expect(actions[1].type).toEqual(FETCH_USER_FAILURE);
|
||||||
|
expect(actions[1].payload).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should sucessfully fetch single user", () => {
|
||||||
|
fetchMock.getOnce(USER_ZAPHOD_URL, userZaphod);
|
||||||
|
|
||||||
|
const store = mockStore({});
|
||||||
|
return store.dispatch(fetchUserByLink(userZaphod)).then(() => {
|
||||||
const actions = store.getActions();
|
const actions = store.getActions();
|
||||||
expect(actions[0].type).toEqual(FETCH_USER_PENDING);
|
expect(actions[0].type).toEqual(FETCH_USER_PENDING);
|
||||||
expect(actions[1].type).toEqual(FETCH_USER_SUCCESS);
|
expect(actions[1].type).toEqual(FETCH_USER_SUCCESS);
|
||||||
@@ -179,12 +206,12 @@ describe("users fetch()", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should fail fetching single user on HTTP 500", () => {
|
it("should fail fetching single user on HTTP 500", () => {
|
||||||
fetchMock.getOnce(USERS_URL + "/zaphod", {
|
fetchMock.getOnce(USER_ZAPHOD_URL, {
|
||||||
status: 500
|
status: 500
|
||||||
});
|
});
|
||||||
|
|
||||||
const store = mockStore({});
|
const store = mockStore({});
|
||||||
return store.dispatch(fetchUser(URL, "zaphod")).then(() => {
|
return store.dispatch(fetchUserByLink(userZaphod)).then(() => {
|
||||||
const actions = store.getActions();
|
const actions = store.getActions();
|
||||||
expect(actions[0].type).toEqual(FETCH_USER_PENDING);
|
expect(actions[0].type).toEqual(FETCH_USER_PENDING);
|
||||||
expect(actions[1].type).toEqual(FETCH_USER_FAILURE);
|
expect(actions[1].type).toEqual(FETCH_USER_FAILURE);
|
||||||
@@ -242,23 +269,26 @@ describe("users fetch()", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("successfully update user", () => {
|
it("successfully update user", () => {
|
||||||
fetchMock.putOnce("http://localhost:8081/api/v2/users/zaphod", {
|
fetchMock.putOnce(USER_ZAPHOD_URL, {
|
||||||
status: 204
|
status: 204
|
||||||
});
|
});
|
||||||
|
fetchMock.getOnce(USER_ZAPHOD_URL, userZaphod);
|
||||||
|
|
||||||
const store = mockStore({});
|
const store = mockStore({});
|
||||||
return store.dispatch(modifyUser(userZaphod)).then(() => {
|
return store.dispatch(modifyUser(userZaphod)).then(() => {
|
||||||
const actions = store.getActions();
|
const actions = store.getActions();
|
||||||
expect(actions.length).toBe(2);
|
expect(actions.length).toBe(3);
|
||||||
expect(actions[0].type).toEqual(MODIFY_USER_PENDING);
|
expect(actions[0].type).toEqual(MODIFY_USER_PENDING);
|
||||||
expect(actions[1].type).toEqual(MODIFY_USER_SUCCESS);
|
expect(actions[1].type).toEqual(MODIFY_USER_SUCCESS);
|
||||||
|
expect(actions[2].type).toEqual(FETCH_USER_PENDING);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should call callback, after successful modified user", () => {
|
it("should call callback, after successful modified user", () => {
|
||||||
fetchMock.putOnce("http://localhost:8081/api/v2/users/zaphod", {
|
fetchMock.putOnce(USER_ZAPHOD_URL, {
|
||||||
status: 204
|
status: 204
|
||||||
});
|
});
|
||||||
|
fetchMock.getOnce(USER_ZAPHOD_URL, userZaphod);
|
||||||
|
|
||||||
let called = false;
|
let called = false;
|
||||||
const callMe = () => {
|
const callMe = () => {
|
||||||
@@ -415,20 +445,6 @@ describe("users reducer", () => {
|
|||||||
expect(newState.byNames["ford"]).toBe(userFord);
|
expect(newState.byNames["ford"]).toBe(userFord);
|
||||||
expect(newState.list.entries).toEqual(["zaphod"]);
|
expect(newState.list.entries).toEqual(["zaphod"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should update state according to MODIFY_USER_SUCCESS action", () => {
|
|
||||||
const newState = reducer(
|
|
||||||
{
|
|
||||||
byNames: {
|
|
||||||
ford: {
|
|
||||||
name: "ford"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
modifyUserSuccess(userFord)
|
|
||||||
);
|
|
||||||
expect(newState.byNames["ford"]).toBe(userFord);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("selector tests", () => {
|
describe("selector tests", () => {
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class DiffStreamingOutput implements StreamingOutput
|
|||||||
public void write(OutputStream output) throws IOException {
|
public void write(OutputStream output) throws IOException {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
builder.retriveContent(output);
|
builder.retrieveContent(output);
|
||||||
}
|
}
|
||||||
catch (RevisionNotFoundException ex)
|
catch (RevisionNotFoundException ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class DiffRootResource {
|
|||||||
repositoryService.getDiffCommand()
|
repositoryService.getDiffCommand()
|
||||||
.setRevision(revision)
|
.setRevision(revision)
|
||||||
.setFormat(diffFormat)
|
.setFormat(diffFormat)
|
||||||
.retriveContent(output);
|
.retrieveContent(output);
|
||||||
} catch (RevisionNotFoundException e) {
|
} catch (RevisionNotFoundException e) {
|
||||||
throw new WebApplicationException(Response.Status.NOT_FOUND);
|
throw new WebApplicationException(Response.Status.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class DiffResourceTest extends RepositoryTestBase {
|
|||||||
public void shouldGetDiffs() throws Exception {
|
public void shouldGetDiffs() throws Exception {
|
||||||
when(diffCommandBuilder.setRevision(anyString())).thenReturn(diffCommandBuilder);
|
when(diffCommandBuilder.setRevision(anyString())).thenReturn(diffCommandBuilder);
|
||||||
when(diffCommandBuilder.setFormat(any())).thenReturn(diffCommandBuilder);
|
when(diffCommandBuilder.setFormat(any())).thenReturn(diffCommandBuilder);
|
||||||
when(diffCommandBuilder.retriveContent(any())).thenReturn(diffCommandBuilder);
|
when(diffCommandBuilder.retrieveContent(any())).thenReturn(diffCommandBuilder);
|
||||||
MockHttpRequest request = MockHttpRequest
|
MockHttpRequest request = MockHttpRequest
|
||||||
.get(DIFF_URL + "revision")
|
.get(DIFF_URL + "revision")
|
||||||
.accept(VndMediaType.DIFF);
|
.accept(VndMediaType.DIFF);
|
||||||
@@ -124,7 +124,7 @@ public class DiffResourceTest extends RepositoryTestBase {
|
|||||||
public void shouldGet404OnMissingRevision() throws Exception {
|
public void shouldGet404OnMissingRevision() throws Exception {
|
||||||
when(diffCommandBuilder.setRevision(anyString())).thenReturn(diffCommandBuilder);
|
when(diffCommandBuilder.setRevision(anyString())).thenReturn(diffCommandBuilder);
|
||||||
when(diffCommandBuilder.setFormat(any())).thenReturn(diffCommandBuilder);
|
when(diffCommandBuilder.setFormat(any())).thenReturn(diffCommandBuilder);
|
||||||
when(diffCommandBuilder.retriveContent(any())).thenThrow(RevisionNotFoundException.class);
|
when(diffCommandBuilder.retrieveContent(any())).thenThrow(RevisionNotFoundException.class);
|
||||||
|
|
||||||
MockHttpRequest request = MockHttpRequest
|
MockHttpRequest request = MockHttpRequest
|
||||||
.get(DIFF_URL + "revision")
|
.get(DIFF_URL + "revision")
|
||||||
@@ -138,7 +138,7 @@ public class DiffResourceTest extends RepositoryTestBase {
|
|||||||
public void shouldGet400OnCrlfInjection() throws Exception {
|
public void shouldGet400OnCrlfInjection() throws Exception {
|
||||||
when(diffCommandBuilder.setRevision(anyString())).thenReturn(diffCommandBuilder);
|
when(diffCommandBuilder.setRevision(anyString())).thenReturn(diffCommandBuilder);
|
||||||
when(diffCommandBuilder.setFormat(any())).thenReturn(diffCommandBuilder);
|
when(diffCommandBuilder.setFormat(any())).thenReturn(diffCommandBuilder);
|
||||||
when(diffCommandBuilder.retriveContent(any())).thenThrow(RevisionNotFoundException.class);
|
when(diffCommandBuilder.retrieveContent(any())).thenThrow(RevisionNotFoundException.class);
|
||||||
|
|
||||||
MockHttpRequest request = MockHttpRequest
|
MockHttpRequest request = MockHttpRequest
|
||||||
.get(DIFF_URL + "ny%0D%0ASet-cookie:%20Tamper=3079675143472450634")
|
.get(DIFF_URL + "ny%0D%0ASet-cookie:%20Tamper=3079675143472450634")
|
||||||
@@ -152,7 +152,7 @@ public class DiffResourceTest extends RepositoryTestBase {
|
|||||||
public void shouldGet400OnUnknownFormat() throws Exception {
|
public void shouldGet400OnUnknownFormat() throws Exception {
|
||||||
when(diffCommandBuilder.setRevision(anyString())).thenReturn(diffCommandBuilder);
|
when(diffCommandBuilder.setRevision(anyString())).thenReturn(diffCommandBuilder);
|
||||||
when(diffCommandBuilder.setFormat(any())).thenReturn(diffCommandBuilder);
|
when(diffCommandBuilder.setFormat(any())).thenReturn(diffCommandBuilder);
|
||||||
when(diffCommandBuilder.retriveContent(any())).thenThrow(RevisionNotFoundException.class);
|
when(diffCommandBuilder.retrieveContent(any())).thenThrow(RevisionNotFoundException.class);
|
||||||
|
|
||||||
MockHttpRequest request = MockHttpRequest
|
MockHttpRequest request = MockHttpRequest
|
||||||
.get(DIFF_URL + "revision?format=Unknown")
|
.get(DIFF_URL + "revision?format=Unknown")
|
||||||
@@ -166,7 +166,7 @@ public class DiffResourceTest extends RepositoryTestBase {
|
|||||||
public void shouldAcceptDiffFormats() throws Exception {
|
public void shouldAcceptDiffFormats() throws Exception {
|
||||||
when(diffCommandBuilder.setRevision(anyString())).thenReturn(diffCommandBuilder);
|
when(diffCommandBuilder.setRevision(anyString())).thenReturn(diffCommandBuilder);
|
||||||
when(diffCommandBuilder.setFormat(any())).thenReturn(diffCommandBuilder);
|
when(diffCommandBuilder.setFormat(any())).thenReturn(diffCommandBuilder);
|
||||||
when(diffCommandBuilder.retriveContent(any())).thenReturn(diffCommandBuilder);
|
when(diffCommandBuilder.retrieveContent(any())).thenReturn(diffCommandBuilder);
|
||||||
|
|
||||||
Arrays.stream(DiffFormat.values()).map(DiffFormat::name).forEach(
|
Arrays.stream(DiffFormat.values()).map(DiffFormat::name).forEach(
|
||||||
this::assertRequestOk
|
this::assertRequestOk
|
||||||
|
|||||||
Reference in New Issue
Block a user