Skip to content

Commit 5399901

Browse files
🔒 all cleaned
1 parent 0a084d9 commit 5399901

File tree

8 files changed

+170
-147
lines changed

8 files changed

+170
-147
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "automatic"
3+
}

pom.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,5 +326,34 @@
326326
</configuration>
327327
</plugin>
328328
</plugins>
329+
330+
<pluginManagement>
331+
<plugins>
332+
<plugin>
333+
<groupId>org.eclipse.m2e</groupId>
334+
<artifactId>lifecycle-mapping</artifactId>
335+
<version>1.0.0</version>
336+
<configuration>
337+
<lifecycleMappingMetadata>
338+
<pluginExecutions>
339+
<pluginExecution>
340+
<pluginExecutionFilter>
341+
<groupId>org.apache.maven.plugins</groupId>
342+
<artifactId>maven-enforcer-plugin</artifactId>
343+
<versionRange>[1.0.0,)</versionRange>
344+
<goals>
345+
<goal>enforce</goal>
346+
</goals>
347+
</pluginExecutionFilter>
348+
<action>
349+
<ignore/>
350+
</action>
351+
</pluginExecution>
352+
</pluginExecutions>
353+
</lifecycleMappingMetadata>
354+
</configuration>
355+
</plugin>
356+
</plugins>
357+
</pluginManagement>
329358
</build>
330359
</project>

src/main/java/com/contentstack/cms/Contentstack.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public Response<LoginDetails> login(String emailId, String password, String tfaT
204204
private void setupLoginCredentials(Response<LoginDetails> loginResponse) throws IOException {
205205
if (loginResponse.isSuccessful()) {
206206
assert loginResponse.body() != null;
207-
logger.info("logged in successfully");
207+
logger.info(loginResponse.body().getNotice());
208208
this.authtoken = loginResponse.body().getUser().getAuthtoken();
209209
this.interceptor.setAuthtoken(this.authtoken);
210210
} else {
@@ -352,8 +352,7 @@ public GlobalField globalField(@NotNull String apiKey, @NotNull String authoriza
352352
* the api key
353353
* @return the content type
354354
*/
355-
public ContentType contentType(
356-
@NotNull String apiKey) {
355+
public ContentType contentType(@NotNull String apiKey) {
357356
if (this.authtoken == null)
358357
throw new IllegalStateException("Please Login to access ContentType instance");
359358
return new ContentType(this.instance, apiKey, null);
@@ -377,16 +376,16 @@ public ContentType contentType(
377376
*
378377
* @param apiKey
379378
* the api key
380-
* @param authorization
379+
* @param managementToken
381380
* the management token
382381
* @return the content type
383382
*/
384383
public ContentType contentType(
385384
@NotNull String apiKey,
386-
@NotNull String authorization) {
385+
@NotNull String managementToken) {
387386
if (this.authtoken == null)
388387
throw new IllegalStateException("Please Login to access ContentType instance");
389-
return new ContentType(this.instance, apiKey, authorization);
388+
return new ContentType(this.instance, apiKey, managementToken);
390389
}
391390

392391
/**
@@ -403,7 +402,6 @@ public ContentType contentType(
403402
public Entry entry(@NotNull String apiKey, @NotNull String managementToken) {
404403
if (this.authtoken == null)
405404
throw new IllegalStateException("Please Login to access Entry instance");
406-
// return new Entry(this.instance, apiKey, managementToken);
407405
return new Entry(this.instance, apiKey, managementToken, "product");
408406
}
409407

@@ -424,7 +422,6 @@ public Entry entry(@NotNull String apiKey, @NotNull String managementToken) {
424422
public Asset asset(@NotNull String apiKey, @NotNull String managementToken) {
425423
if (this.authtoken == null)
426424
throw new IllegalStateException("Please Login to access Asset instance");
427-
// return new Entry(this.instance, apiKey, managementToken);
428425
return new Asset(this.instance, apiKey, managementToken);
429426
}
430427

src/main/java/com/contentstack/cms/contenttype/ContentTypeService.java

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,59 @@
99

1010
public interface ContentTypeService {
1111

12-
@GET("content_types")
13-
Call<ResponseBody> fetch(@HeaderMap Map<String, String> headers,
14-
@QueryMap Map<String, Object> query);
15-
16-
@GET("content_types/{content_type_uid}")
17-
Call<ResponseBody> single(@HeaderMap Map<String, String> headers,
18-
@Path("content_type_uid") String contentTypeUid,
19-
@QueryMap Map<String, Object> queryParam);
20-
21-
@POST("content_types")
22-
Call<ResponseBody> create(@HeaderMap Map<String, String> headers,
23-
@Body JSONObject body);
24-
25-
@PUT("content_types/{content_type_uid}")
26-
Call<ResponseBody> update(@Path("content_type_uid") String contentTypeUid,
27-
@HeaderMap Map<String, String> headers,
28-
@Body JSONObject body);
29-
30-
@PUT("content_types/{content_type_uid}")
31-
Call<ResponseBody> visibilityRule(@Path("content_type_uid") String contentTypeUid,
32-
@HeaderMap Map<String, String> headers,
33-
@Body JSONObject body);
34-
35-
@DELETE("content_types/{content_type_uid}")
36-
Call<ResponseBody> delete(@Path("content_type_uid") String contentTypeUid,
37-
@HeaderMap Map<String, String> headers);
38-
39-
@DELETE("content_types/{content_type_uid}")
40-
Call<ResponseBody> delete(@Path("content_type_uid") String contentTypeUid,
41-
@HeaderMap Map<String, String> headers,
42-
@Query("force") Boolean force);
43-
44-
@GET("content_types/{content_type_uid}/references")
45-
Call<ResponseBody> reference(@Path("content_type_uid") String contentTypeUid,
46-
@HeaderMap Map<String, String> headers);
47-
48-
@GET("content_types/{content_type_uid}/references?include_global_fields=true")
49-
Call<ResponseBody> referenceIncludeGlobalField(@Path("content_type_uid") String contentTypeUid,
50-
@HeaderMap Map<String, String> headers);
51-
52-
@GET("content_types/{content_type_uid}/export")
53-
Call<ResponseBody> export(@Path("content_type_uid") String contentTypeUid,
54-
@HeaderMap Map<String, String> headers,
55-
@Query("version") int version);
56-
57-
@GET("content_types/{content_type_uid}/export")
58-
Call<ResponseBody> export(@Path("content_type_uid") String contentTypeUid,
59-
@HeaderMap Map<String, String> headers);
60-
61-
@POST("content_types/import")
62-
Call<ResponseBody> imports(@HeaderMap Map<String, String> headers);
63-
64-
@POST("content_types/import?overwrite=true")
65-
Call<ResponseBody> importOverwrite(@HeaderMap Map<String, String> headers);
12+
@GET("content_types")
13+
Call<ResponseBody> fetch(@HeaderMap Map<String, String> headers,
14+
@QueryMap Map<String, Object> query);
15+
16+
@GET("content_types/{content_type_uid}")
17+
Call<ResponseBody> single(@HeaderMap Map<String, String> headers,
18+
@Path("content_type_uid") String contentTypeUid,
19+
@QueryMap Map<String, Object> queryParam);
20+
21+
@POST("content_types")
22+
Call<ResponseBody> create(@HeaderMap Map<String, String> headers,
23+
@Body JSONObject body);
24+
25+
@PUT("content_types/{content_type_uid}")
26+
Call<ResponseBody> update(@Path("content_type_uid") String contentTypeUid,
27+
@HeaderMap Map<String, String> headers,
28+
@Body JSONObject body);
29+
30+
@PUT("content_types/{content_type_uid}")
31+
Call<ResponseBody> visibilityRule(@Path("content_type_uid") String contentTypeUid,
32+
@HeaderMap Map<String, String> headers,
33+
@Body JSONObject body);
34+
35+
@DELETE("content_types/{content_type_uid}")
36+
Call<ResponseBody> delete(@Path("content_type_uid") String contentTypeUid,
37+
@HeaderMap Map<String, String> headers);
38+
39+
@DELETE("content_types/{content_type_uid}")
40+
Call<ResponseBody> delete(@Path("content_type_uid") String contentTypeUid,
41+
@HeaderMap Map<String, String> headers,
42+
@Query("force") Boolean force);
43+
44+
@GET("content_types/{content_type_uid}/references")
45+
Call<ResponseBody> reference(@Path("content_type_uid") String contentTypeUid,
46+
@HeaderMap Map<String, String> headers);
47+
48+
@GET("content_types/{content_type_uid}/references?include_global_fields=true")
49+
Call<ResponseBody> referenceIncludeGlobalField(@Path("content_type_uid") String contentTypeUid,
50+
@HeaderMap Map<String, String> headers);
51+
52+
@GET("content_types/{content_type_uid}/export")
53+
Call<ResponseBody> export(@Path("content_type_uid") String contentTypeUid,
54+
@HeaderMap Map<String, String> headers,
55+
@Query("version") int version);
56+
57+
@GET("content_types/{content_type_uid}/export")
58+
Call<ResponseBody> export(@Path("content_type_uid") String contentTypeUid,
59+
@HeaderMap Map<String, String> headers);
60+
61+
@POST("content_types/import")
62+
Call<ResponseBody> imports(@HeaderMap Map<String, String> headers);
63+
64+
@POST("content_types/import?overwrite=true")
65+
Call<ResponseBody> importOverwrite(@HeaderMap Map<String, String> headers);
6666

6767
}

src/test/java/com/contentstack/cms/contenttype/ContentTypeAPITest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ class ContentTypeAPITest {
2323

2424
public static ContentType contentType;
2525
public static Logger logger = Logger.getLogger(ContentTypeAPITest.class.getName());
26-
private String contentTypeUid = "headlines";
26+
private String contentTypeUid = "product";
2727

2828
@BeforeAll
2929
static void setupBeforeStart() throws IOException {
3030
Dotenv env = Dotenv.load();
3131
Contentstack contentstack = new Contentstack.Builder().build();
3232
contentstack.login(env.get("username"), env.get("password"));
33-
String apiKey = Objects.requireNonNull(env.get("apiKey"));
34-
contentType = contentstack.contentType(apiKey);
33+
String apiKey = Objects.requireNonNull(env.get("apiKey1"));
34+
String managementToken = Objects.requireNonNull(env.get("managementToken1"));
35+
contentType = contentstack.contentType(apiKey, managementToken);
3536
}
3637

3738
@Test
@@ -63,7 +64,7 @@ void testSingleApi() throws IOException {
6364
mapQuery.put("version", 1);
6465
mapQuery.put("include_global_field_schema", true);
6566
Response<ResponseBody> response = contentType.single(contentTypeUid, mapQuery).execute();
66-
assert response.body() != null;
67+
//assert response.body() != null;
6768
if (response.isSuccessful()) {
6869
JsonObject jsonObject = Utils.toJson(response);
6970
Assertions.assertTrue(jsonObject.has("content_type"));
@@ -84,7 +85,7 @@ void testCreate() throws IOException {
8485
Assertions.assertTrue(jsonObject.has("content_type"));
8586
} else {
8687
logger.severe("testCreate is failing");
87-
Assertions.fail();
88+
Assertions.fail("Content Type Creation failed");
8889
}
8990
}
9091

Lines changed: 53 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,62 @@
11
package com.contentstack.cms.core;
22

3-
import org.junit.jupiter.api.Test;
4-
import org.junit.jupiter.api.condition.*;
5-
6-
import java.lang.annotation.ElementType;
7-
import java.lang.annotation.Retention;
8-
import java.lang.annotation.RetentionPolicy;
9-
import java.lang.annotation.Target;
10-
113
/**
124
* The type Test utils.
135
*/
146
class TestOSBasedUtils {
157

16-
/**
17-
* This test only runs with up to date jr es.
18-
*/
19-
@Test
20-
@DisabledOnJre(JRE.OTHER)
21-
void thisTestOnlyRunsWithUpToDateJREs() {
22-
// this test will only run on Java 8, 9, 10, and 11.
23-
}
24-
25-
/**
26-
* Only on macOS.
27-
*/
28-
@Test
29-
@EnabledOnOs(OS.MAC)
30-
void onlyOnMacOs() {
31-
// ...
32-
}
33-
34-
/**
35-
* Test on mac.
36-
*/
37-
@TestOnMac
38-
void testOnMac() {
39-
// ...
40-
}
41-
42-
/**
43-
* On linux or Mac.
44-
*/
45-
@Test
46-
@EnabledOnOs({OS.LINUX, OS.MAC})
47-
void onLinuxOrMac() {
48-
// ...
49-
}
50-
51-
/**
52-
* Not on Windows.
53-
*/
54-
@Test
55-
@DisabledOnOs(OS.WINDOWS)
56-
void notOnWindows() {
57-
// ...
58-
}
59-
60-
/**
61-
* The interface Test on Mac.
62-
*/
63-
@Target(ElementType.METHOD)
64-
@Retention(RetentionPolicy.RUNTIME)
65-
@Test
66-
@EnabledOnOs(OS.MAC)
67-
@interface TestOnMac {
68-
}
8+
// /**
9+
// * This test only runs with up to date jr es.
10+
// */
11+
// @Test
12+
// @DisabledOnJre(JRE.OTHER)
13+
// void thisTestOnlyRunsWithUpToDateJREs() {
14+
// // this test will only run on Java 8, 9, 10, and 11.
15+
// }
16+
//
17+
// /**
18+
// * Only on macOS.
19+
// */
20+
// @Test
21+
// @EnabledOnOs(OS.MAC)
22+
// void onlyOnMacOs() {
23+
// // ...
24+
// }
25+
//
26+
// /**
27+
// * Test on mac.
28+
// */
29+
// @TestOnMac
30+
// void testOnMac() {
31+
// // ...
32+
// }
33+
//
34+
// /**
35+
// * On linux or Mac.
36+
// */
37+
// @Test
38+
// @EnabledOnOs({OS.LINUX, OS.MAC})
39+
// void onLinuxOrMac() {
40+
// // ...
41+
// }
42+
//
43+
// /**
44+
// * Not on Windows.
45+
// */
46+
// @Test
47+
// @DisabledOnOs(OS.WINDOWS)
48+
// void notOnWindows() {
49+
// // ...
50+
// }
51+
//
52+
// /**
53+
// * The interface Test on Mac.
54+
// */
55+
// @Target(ElementType.METHOD)
56+
// @Retention(RetentionPolicy.RUNTIME)
57+
// @Test
58+
// @EnabledOnOs(OS.MAC)
59+
// @interface TestOnMac {
60+
// }
6961

7062
}

src/test/java/com/contentstack/cms/core/TestUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.contentstack.cms.core;
22

3+
import org.jetbrains.annotations.Contract;
34
import org.junit.jupiter.api.Assertions;
45
import org.junit.jupiter.api.Test;
56

@@ -17,6 +18,7 @@ public static boolean isValid(String url) {
1718
}
1819

1920
@Test
21+
@Contract(value = " -> fail", pure = true)
2022
void testUtilConstructor() {
2123
try {
2224
new Util();
@@ -26,7 +28,6 @@ void testUtilConstructor() {
2628
}
2729

2830
@Test
29-
@TestOSBasedUtils.TestOnMac
3031
void testDefaultUserAgent() {
3132
String result = Util.defaultUserAgent();
3233
String version = System.getProperty("java.version");

0 commit comments

Comments
 (0)