Skip to content

Commit ae37475

Browse files
committed
Updated with projects formatting style.
1 parent 8077fac commit ae37475

File tree

2 files changed

+114
-130
lines changed

2 files changed

+114
-130
lines changed

src/main/java/org/gitlab4j/api/models/Snippet.java

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright (c) 2017 Greg Messner <[email protected]>
4+
* Copyright (c) 2018 Greg Messner <[email protected]>
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy of
77
* this software and associated documentation files (the "Software"), to deal in
@@ -44,24 +44,23 @@ public class Snippet {
4444
private String content;
4545
private String rawUrl;
4646
private Visibility visibility;
47-
private String description;
47+
private String description;
4848

4949
public Snippet() {
50-
5150
}
52-
51+
5352
public Snippet(String title, String fileName, String content, Visibility visibility, String description) {
54-
this(title, fileName, content);
55-
this.visibility = visibility;
56-
this.description = description;
53+
this(title, fileName, content);
54+
this.visibility = visibility;
55+
this.description = description;
5756
}
58-
57+
5958
public Snippet(String title, String fileName, String content) {
60-
this.title = title;
61-
this.fileName = fileName;
62-
this.content = content;
59+
this.title = title;
60+
this.fileName = fileName;
61+
this.content = content;
6362
}
64-
63+
6564
public Author getAuthor() {
6665
return this.author;
6766
}
@@ -126,35 +125,35 @@ public void setWebUrl(String webUrl) {
126125
this.webUrl = webUrl;
127126
}
128127

129-
public String getContent() {
130-
return content;
131-
}
128+
public String getContent() {
129+
return content;
130+
}
132131

133-
public void setContent(String content) {
134-
this.content = content;
135-
}
132+
public void setContent(String content) {
133+
this.content = content;
134+
}
136135

137-
public String getRawUrl() {
138-
return rawUrl;
139-
}
136+
public String getRawUrl() {
137+
return rawUrl;
138+
}
140139

141-
public void setRawUrl(String rawUrl) {
142-
this.rawUrl = rawUrl;
143-
}
140+
public void setRawUrl(String rawUrl) {
141+
this.rawUrl = rawUrl;
142+
}
144143

145-
public Visibility getVisibility() {
146-
return visibility;
147-
}
144+
public Visibility getVisibility() {
145+
return visibility;
146+
}
148147

149-
public void setVisibility(Visibility visibility) {
150-
this.visibility = visibility;
151-
}
148+
public void setVisibility(Visibility visibility) {
149+
this.visibility = visibility;
150+
}
152151

153-
public String getDescription() {
154-
return description;
155-
}
152+
public String getDescription() {
153+
return description;
154+
}
156155

157-
public void setDescription(String description) {
158-
this.description = description;
159-
}
156+
public void setDescription(String description) {
157+
this.description = description;
158+
}
160159
}

src/test/java/org/gitlab4j/api/TestSnippetsApi.java

Lines changed: 79 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class TestSnippetsApi {
1717

1818
private static final String TEST_HOST_URL;
1919
private static final String TEST_PRIVATE_TOKEN;
20-
20+
2121
static {
2222
TEST_HOST_URL = TestUtils.getProperty("TEST_HOST_URL");
2323
TEST_PRIVATE_TOKEN = TestUtils.getProperty("TEST_PRIVATE_TOKEN");
@@ -29,8 +29,7 @@ public class TestSnippetsApi {
2929
private static final String TEST_SNIPPET_CONTENT_1 = "test-snippet-content-1";
3030
private static final String TEST_SNIPPET_CONTENT_2 = "test-snippet-content-2";
3131
private static final String TEST_SNIPPET_DESCRIPTION_1 = "test-snippet-description-1";
32-
33-
32+
3433
@BeforeClass
3534
public static void setup() {
3635

@@ -50,95 +49,81 @@ public static void setup() {
5049
System.err.print(problems);
5150
}
5251
}
53-
54-
@Test
55-
public void testCreate() throws GitLabApiException {
56-
Snippet snippet = createSnippet(new Snippet(TEST_SNIPPET_TITLE_1,
57-
TEST_SNIPPET_FILE_NAME_1,
58-
TEST_SNIPPET_CONTENT_1));
59-
assertEquals(TEST_SNIPPET_TITLE_1, snippet.getTitle());
60-
assertEquals(TEST_SNIPPET_FILE_NAME_1, snippet.getFileName());
61-
assertNull(snippet.getContent());
62-
63-
deleteSnippet(snippet);
64-
}
65-
66-
@Test
67-
public void testDelete() throws GitLabApiException {
68-
Snippet snippet = createSnippet(new Snippet(TEST_SNIPPET_TITLE_1,
69-
TEST_SNIPPET_FILE_NAME_1,
70-
TEST_SNIPPET_CONTENT_1));
71-
deleteSnippet(snippet);
72-
73-
SnippetsApi api = gitLabApi.getSnippetApi();
74-
List<Snippet> snippets = api.getSnippets();
75-
boolean found = snippets.stream().anyMatch(
76-
s -> s.getId().equals(snippet.getId()));
77-
assertFalse(found);
78-
}
79-
80-
@Test
81-
public void testList() throws GitLabApiException {
82-
Snippet snippet1 = createSnippet(new Snippet(TEST_SNIPPET_TITLE_1,
83-
TEST_SNIPPET_FILE_NAME_1,
84-
TEST_SNIPPET_CONTENT_1));
85-
Snippet snippet2 = createSnippet(new Snippet(TEST_SNIPPET_TITLE_1,
86-
TEST_SNIPPET_FILE_NAME_1,
87-
TEST_SNIPPET_CONTENT_2));
88-
89-
SnippetsApi api = gitLabApi.getSnippetApi();
90-
List<Snippet> snippets = api.getSnippets(true);
91-
92-
assertTrue(snippets.size() >= 2);
93-
assertTrue(snippets.stream().anyMatch(s -> s.getContent().equals(TEST_SNIPPET_CONTENT_1)));
94-
assertTrue(snippets.stream().anyMatch(s -> s.getContent().equals(TEST_SNIPPET_CONTENT_2)));
95-
96-
97-
deleteSnippet(snippet1);
98-
deleteSnippet(snippet2);
99-
}
100-
101-
@Test
102-
public void testSnippetContent() throws GitLabApiException {
103-
Snippet snippet = createSnippet(
104-
new Snippet(TEST_SNIPPET_TITLE_1, TEST_SNIPPET_FILE_NAME_1, TEST_SNIPPET_CONTENT_1));
105-
SnippetsApi api = gitLabApi.getSnippetApi();
106-
String snippetContent = api.getSnippetContent(snippet.getId());
107-
assertEquals(TEST_SNIPPET_CONTENT_1, snippetContent);
108-
deleteSnippet(snippet);
109-
}
110-
111-
@Test
112-
public void testRetrieveSnippet() throws GitLabApiException {
113-
Snippet snippet = createSnippet (new Snippet(TEST_SNIPPET_TITLE_1,
114-
TEST_SNIPPET_FILE_NAME_1,
115-
TEST_SNIPPET_CONTENT_1,
116-
Visibility.INTERNAL,
117-
TEST_SNIPPET_DESCRIPTION_1));
118-
119-
SnippetsApi api = gitLabApi.getSnippetApi();
120-
Snippet savedSnippet = api.getSnippet(snippet.getId(), true);
121-
122-
assertEquals(TEST_SNIPPET_TITLE_1, savedSnippet.getTitle());
123-
assertEquals(TEST_SNIPPET_FILE_NAME_1, savedSnippet.getFileName());
124-
assertEquals(TEST_SNIPPET_CONTENT_1, savedSnippet.getContent());
125-
assertEquals(TEST_SNIPPET_DESCRIPTION_1, savedSnippet.getDescription());
126-
127-
deleteSnippet(savedSnippet);
128-
}
129-
130-
public void deleteSnippet(Snippet snippet) throws GitLabApiException {
131-
SnippetsApi api = gitLabApi.getSnippetApi();
132-
api.deleteSnippet(snippet.getId());
133-
}
134-
135-
public Snippet createSnippet(Snippet snippet) throws GitLabApiException {
136-
SnippetsApi api = gitLabApi.getSnippetApi();
137-
return api.createSnippet(snippet.getTitle(),
138-
snippet.getFileName(),
139-
snippet.getContent(),
140-
snippet.getVisibility(),
141-
snippet.getDescription());
142-
}
143-
52+
53+
@Test
54+
public void testCreate() throws GitLabApiException {
55+
Snippet snippet = createSnippet(
56+
new Snippet(TEST_SNIPPET_TITLE_1, TEST_SNIPPET_FILE_NAME_1, TEST_SNIPPET_CONTENT_1));
57+
assertEquals(TEST_SNIPPET_TITLE_1, snippet.getTitle());
58+
assertEquals(TEST_SNIPPET_FILE_NAME_1, snippet.getFileName());
59+
assertNull(snippet.getContent());
60+
61+
deleteSnippet(snippet);
62+
}
63+
64+
@Test
65+
public void testDelete() throws GitLabApiException {
66+
Snippet snippet = createSnippet(
67+
new Snippet(TEST_SNIPPET_TITLE_1, TEST_SNIPPET_FILE_NAME_1, TEST_SNIPPET_CONTENT_1));
68+
deleteSnippet(snippet);
69+
70+
SnippetsApi api = gitLabApi.getSnippetApi();
71+
List<Snippet> snippets = api.getSnippets();
72+
boolean found = snippets.stream().anyMatch(s -> s.getId().equals(snippet.getId()));
73+
assertFalse(found);
74+
}
75+
76+
@Test
77+
public void testList() throws GitLabApiException {
78+
Snippet snippet1 = createSnippet(new Snippet(TEST_SNIPPET_TITLE_1, TEST_SNIPPET_FILE_NAME_1, TEST_SNIPPET_CONTENT_1));
79+
Snippet snippet2 = createSnippet(new Snippet(TEST_SNIPPET_TITLE_1, TEST_SNIPPET_FILE_NAME_1, TEST_SNIPPET_CONTENT_2));
80+
81+
SnippetsApi api = gitLabApi.getSnippetApi();
82+
List<Snippet> snippets = api.getSnippets(true);
83+
84+
assertTrue(snippets.size() >= 2);
85+
assertTrue(snippets.stream().anyMatch(s -> s.getContent().equals(TEST_SNIPPET_CONTENT_1)));
86+
assertTrue(snippets.stream().anyMatch(s -> s.getContent().equals(TEST_SNIPPET_CONTENT_2)));
87+
88+
deleteSnippet(snippet1);
89+
deleteSnippet(snippet2);
90+
}
91+
92+
@Test
93+
public void testSnippetContent() throws GitLabApiException {
94+
Snippet snippet = createSnippet(
95+
new Snippet(TEST_SNIPPET_TITLE_1, TEST_SNIPPET_FILE_NAME_1, TEST_SNIPPET_CONTENT_1));
96+
SnippetsApi api = gitLabApi.getSnippetApi();
97+
String snippetContent = api.getSnippetContent(snippet.getId());
98+
assertEquals(TEST_SNIPPET_CONTENT_1, snippetContent);
99+
deleteSnippet(snippet);
100+
}
101+
102+
@Test
103+
public void testRetrieveSnippet() throws GitLabApiException {
104+
Snippet snippet = createSnippet(new Snippet(TEST_SNIPPET_TITLE_1, TEST_SNIPPET_FILE_NAME_1,
105+
TEST_SNIPPET_CONTENT_1, Visibility.INTERNAL, TEST_SNIPPET_DESCRIPTION_1));
106+
107+
SnippetsApi api = gitLabApi.getSnippetApi();
108+
Snippet savedSnippet = api.getSnippet(snippet.getId(), true);
109+
110+
assertEquals(TEST_SNIPPET_TITLE_1, savedSnippet.getTitle());
111+
assertEquals(TEST_SNIPPET_FILE_NAME_1, savedSnippet.getFileName());
112+
assertEquals(TEST_SNIPPET_CONTENT_1, savedSnippet.getContent());
113+
assertEquals(TEST_SNIPPET_DESCRIPTION_1, savedSnippet.getDescription());
114+
115+
deleteSnippet(savedSnippet);
116+
}
117+
118+
public void deleteSnippet(Snippet snippet) throws GitLabApiException {
119+
SnippetsApi api = gitLabApi.getSnippetApi();
120+
api.deleteSnippet(snippet.getId());
121+
}
122+
123+
public Snippet createSnippet(Snippet snippet) throws GitLabApiException {
124+
SnippetsApi api = gitLabApi.getSnippetApi();
125+
return api.createSnippet(snippet.getTitle(), snippet.getFileName(), snippet.getContent(),
126+
snippet.getVisibility(), snippet.getDescription());
127+
}
128+
144129
}

0 commit comments

Comments
 (0)