This week's giveaway is in the Java in General forum.
We're giving away four copies of Java Challengers and have Rafael del Nero on-line!
See this thread for details.
Win a copy of Java Challengers this week in the Java in General forum!

pragati dev

Greenhorn
+ Follow
since May 10, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by pragati dev

I have a string as "Jul 22, 2020, 11:56:51 PM" and I want to convert it into "DD/MM/YYYY a" format so that the output is 21/07/2020 11:56:51 PM I have tried but this gives me time difference of 5:30 hours I want the same date, ExportObj has a proprty date which is of type String, Output I'm getting is- 07/22/2020 06:26 PM
9 months ago
* so that the procedure is called only once for multiple transaction Objects
in JDBC I'm doing this

here we are doing add batch I was to do the same using SimpleJDBCCall but I'll have to use forEach instead of it can you please suggest the alternative approach so that the proc will not be called only once like in above code?
Hi, do we have addBatch functionality in JPA??
I have to call a procedure for multiple transaction Id's so instead of calling the procedure multiple times using for loop, can you please suggest me if there any functionality in JPA just like JDBC where we do addbatch()
11 months ago
Hi I'm using thymeleaf and to insert a template  into userExport I'm using parametrized fragment as follows




getting this error
Caused by: org.attoparser.ParseException: Error resolving fragment: "~{'fragment/transactionValidationExport.html' :: formField (validationDataList=${userObject.userValidationDTOs})}": template or fragment could not be resolved (template: "reports/userExport" - line 129, col 14)
Can someone please take a look and guide me where am I wrong in this??



11 months ago
I have converted my UserDTO into json string but it's property createDate is being converted as
"createdDate":{
    "epochSecond":1589718619,
    "nano":876000000
 }
this is causing error
: Bad Request: JSON parse error: Unexpected token (START_OBJECT), expected one of [VALUE_STRING, VALUE_NUMBER_INT, VALUE_NUMBER_FLOAT] for java.time.Instant value; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Unexpected token (START_OBJECT), expected one of [VALUE_STRING, VALUE_NUMBER_INT, VALUE_NUMBER_FLOAT] for java.time.Instant value
at [Source: (ByteArrayInputStream); line: 1, column: 33] (through reference chain: com.fis.pta.service.dto.UserDTO["createdDate"])
any suggestions please to resolve it?
11 months ago
Hi,
 UserDTO is an Object whose values are set under createEntity method which executes when I run createUser() -test method  and that UserDTO has createDate field which is of Instant type and it is not being set in createEntity method is gets updated automatically
11 months ago
Thanks your solution did help, I've added the dependency but now when I execute the test method I get following error and when I debugged it I got createDate as
"createdDate":{
     "epochSecond":1589718619,
     "nano":876000000
  }
and createDate is a field of User object which of type Instant, can you please suggest how to resolve it?


   

: Bad Request: JSON parse error: Unexpected token (START_OBJECT), expected one of [VALUE_STRING, VALUE_NUMBER_INT, VALUE_NUMBER_FLOAT] for java.time.Instant value; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Unexpected token (START_OBJECT), expected one of [VALUE_STRING, VALUE_NUMBER_INT, VALUE_NUMBER_FLOAT] for java.time.Instant value
at [Source: (ByteArrayInputStream); line: 1, column: 33] (through reference chain: com.fis.pta.service.dto.UserDTO["createdDate"])
11 months ago
Thanks for this but when I also added WebConfig class as below I'm getting following error can you please suggest something
[code]
@Configuration
@ComponentScan({ "com.web.rest" })
@EnableWebMvc

public class WebConfig extends WebMvcConfigurationSupport {

 @Bean
 public MultipartResolver multipartResolver() {
   CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
   return multipartResolver;
 }


}
[code]

Error creating bean with name 'multipartResolver' defined in class path resource [com/web/rest/WebConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.multipart.MultipartResolver]: Factory method 'multipartResolver' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory  
11 months ago
Here I want to write a test for following controller method, on executing method of the testclass I'm getting an error as required part formData is not present, I've tried finding a solution for testing an object having 'RequestPart' annotation but no luck, can someone please take a look and suggest a way to write JUNIT test for @RequestPart

[code]

@PostMapping("/user")
public ResponseEntity<UserDTO> createUser(@RequestPart(value = "files", required= false) MultipartFile[] files,
@RequestPart("formData") UserDTO userDTO) throws URISyntaxException {

userService.save(userDTO, files);

//....

}

Inside TestClass-

@BeforeEach
public void initTest()
{
user = createEntity(em);// inside this method I've set all the properties of userDTO and 'user' is a reference variable to User class
}

public void createUser() throws Exception {

UserDTO userDTO = userMapper.toDto(user);

mockMvc.
perform(post("/api/user")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(userDTO)))
.andExpect(status().isCreated());
}
1 year ago