Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test #44

Closed
wants to merge 15 commits into from
Closed

Test #44

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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>dev.nmarulo</groupId>
<artifactId>despensa-rest-api</artifactId>
<version>0.0.1</version>
<version>1.0.0</version>
<packaging>war</packaging>
<name>Despensa-app rest-api</name>
<description>
Expand Down
28 changes: 26 additions & 2 deletions src/main/java/dev/nmarulo/depensaapp/ServletInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,35 @@
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {
import java.net.URL;
import java.util.HashMap;

public class ServletInitializer extends SpringBootServletInitializer {

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
Integer.valueOf(3)
.compareTo(2);
new Integer(3).compareTo(2);
HashMap<URL, Integer> hits = new HashMap<>();
for (HashMap.Entry<URL, Integer> e : hits.entrySet()) {
// ... This can become very slow for larger hashmaps of URLS.
}
String x = "foo";
if (x.equals(null)) {
//doSomething();
}
Integer value = 1;
try {
// ...
} catch (Exception e) {
// ...
value = null; // Value set to null within a catch block
// ...
}
//value.member += 1;

return application.sources(DespensaRestApiApplication.class);
}

}
38 changes: 38 additions & 0 deletions src/main/java/dev/nmarulo/depensaapp/commons/Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package dev.nmarulo.depensaapp.commons;

public abstract class Test {

public static void test() {
int a = 0;
}

public void test0() {
for (int i = 0; i < 10; i++) {
System.out.println("test0" + i);
System.out.println("test0" + i);
System.out.println("test0" + i);
System.out.println("test0" + i);

return;
}
}

public void test1() {
for (int i = 0; i < 10; i++) {
System.out.println("test0" + i);
System.out.println("test0" + i);
System.out.println("test0" + i);
System.out.println("test0" + i);
}

for (int i = 0; i < 10; i++) {
System.out.println("test0" + i);
System.out.println("test0" + i);
System.out.println("test0" + i);
System.out.println("test0" + i);

return;
}
}

}
16 changes: 16 additions & 0 deletions src/main/java/dev/nmarulo/depensaapp/commons/gson/GsonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
import org.springframework.core.ResolvableType;
import org.springframework.stereotype.Component;

import java.net.URL;
import java.util.HashMap;
import java.util.List;

@Component
@RequiredArgsConstructor
public class GsonUtil {
// --
// --

private final Gson gson;

Expand All @@ -23,6 +27,18 @@ public <R> R convertTo(Object object, Class<?> clazz) {
return fromJsonTo(json, TypeToken.getParameterized(List.class, clazz));
}

Integer.valueOf(3)
.compareTo(2);
new Integer(3).compareTo(2);
HashMap<URL, Integer> hits = new HashMap<>();
for (HashMap.Entry<URL, Integer> e : hits.entrySet()) {
// ... This can become very slow for larger hashmaps of URLS.
}
String x = "foo";
if (x.equals(null)) {
//doSomething();
}

return fromJsonTo(json, TypeToken.get(clazz));
}

Expand Down
58 changes: 58 additions & 0 deletions src/test/java/dev/nmarulo/depensaapp/CrudServiceTestUtil2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package dev.nmarulo.depensaapp;

import lombok.Getter;
import lombok.Value;

import java.util.List;

@Getter
public abstract class CrudServiceTestUtil2<E, R, T, ID> {

private E request;

private R response;

private T entity;

private T entitySaveResult;

private ID id;

private final List<R> responseList;

private final List<T> entityList;

public CrudServiceTestUtil2() {
setInit();
this.responseList = List.of(this.response);
this.entityList = List.of(this.entity);
}

public abstract Init<E, R, T, ID> init();

private void setInit() {
Init<E, R, T, ID> init = init();

this.request = init.getRequest();
this.response = init.getResponse();
this.entity = init.getEntity();
this.entitySaveResult = init.getEntitySaveResult();
this.id = init.getId();
}

@Value(staticConstructor = "of")
public static class Init<E, R, T, ID> {

E request;

R response;

T entity;

T entitySaveResult;

ID id;

}

}
14 changes: 14 additions & 0 deletions src/test/java/dev/nmarulo/depensaapp/app/Test001.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package dev.nmarulo.depensaapp;

import lombok.Getter;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
@Getter
class TypeDishServiceTest {


}