Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mytime
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Narendar Vakiti
mytime
Commits
fdd36e72
Commit
fdd36e72
authored
Jun 24, 2019
by
shiva dandem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deleted unnecessary test controller
parent
ec748ad5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
170 deletions
+0
-170
AccountControllerTestx.java
...m/nisum/myteam/controllertest/AccountControllerTestx.java
+0
-170
No files found.
src/test/java/com/nisum/myteam/controllertest/AccountControllerTestx.java
deleted
100644 → 0
View file @
ec748ad5
package
com
.
nisum
.
myteam
.
controllertest
;
import
java.util.Map
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
delete
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
post
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
put
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
org.bson.types.ObjectId
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
org.mockito.MockitoAnnotations
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.result.MockMvcResultMatchers
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.nisum.myteam.controller.AccountController
;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.service.impl.AccountService
;
public
class
AccountControllerTest
{
@Mock
AccountService
Accountserviceimpl
;
@InjectMocks
AccountController
AccountController
;
private
MockMvc
mockMvc
;
@Before
public
void
setup
()
{
MockitoAnnotations
.
initMocks
(
this
);
mockMvc
=
MockMvcBuilders
.
standaloneSetup
(
AccountController
).
build
();
}
//
// public void createAccountTest()
// {
//
// }
// @Test
// public void testaddAccount() throws Exception {
// List<String> list = new ArrayList<>();
// list.add("16620");
// list.add("16632");
// String responce=null;
// Account persistedAccount=null;
// Account account = new Account(
// "Acc003", "Nisum", 3,
// "Y","HYD","RetailS",list);
// when(Accountserviceimpl.createAccount(account))
// .thenReturn(persistedAccount);
// String jsonvalue = (new ObjectMapper())
// .writeValueAsString(account).toString();
// mockMvc.perform(post("/account/accounts").param("action","N")
// .contentType(MediaType.APPLICATION_JSON_VALUE)
// .content(jsonvalue))
// .andExpect(MockMvcResultMatchers.status().isOk());
// }
@Test
public
void
testgetAccountNames
()
throws
Exception
{
List
<
Map
<
Object
,
Object
>>
Account
=
CreateAccountDetails
();
when
(
Accountserviceimpl
.
getAccountsList
()).
thenReturn
(
Account
);
mockMvc
.
perform
(
get
(
"/account/accountNames"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
}
@Test
public
void
testgetAccount
()
throws
Exception
{
List
<
Account
>
Account
=
null
;
when
(
Accountserviceimpl
.
getAccounts
()).
thenReturn
(
Account
);
mockMvc
.
perform
(
get
(
"/account/accounts"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
}
// @Test
// public void testupdateAccount() throws Exception {
// List<String> list = new ArrayList<>();
// list.add("16620");
// list.add("16632");
// String responce=null;
// Account accountUpdated=null;
// Account account = new Account(
// "Acc003", "Nisum", 3,
// "Y","HYD","RetailS",list);
// when(Accountserviceimpl.createAccount(account))
// .thenReturn(accountUpdated);
// String jsonvalue = (new ObjectMapper())
// .writeValueAsString(account).toString();
// mockMvc.perform(post("/account/accounts").param("action","U")
// .contentType(MediaType.APPLICATION_JSON_VALUE)
// .content(jsonvalue))
// .andExpect(MockMvcResultMatchers.status().isOk());
// }
//
@Test
public
void
testdeleteAccount
()
throws
Exception
{
mockMvc
.
perform
(
delete
(
"/account/accounts"
).
param
(
"accountId"
,
"Acc002"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
Accountserviceimpl
).
deleteAccount
(
"Acc002"
);
}
private
List
<
Map
<
Object
,
Object
>>
CreateAccountDetails
()
{
List
<
Map
<
Object
,
Object
>>
data
=
new
ArrayList
<
Map
<
Object
,
Object
>>
();
HashMap
<
Object
,
Object
>
map1
=
new
HashMap
<
Object
,
Object
>();
HashMap
<
Object
,
Object
>
map2
=
new
HashMap
<
Object
,
Object
>();
Account
data1
=
new
Account
();
// data1.setId(new ObjectId("5976ef15874c902c98b8a05d"));
data1
.
setAccountId
(
"Acc004"
);
data1
.
setAccountName
(
"Govt"
);
data1
.
setAccountProjectSequence
(
4
);
data1
.
setClientAddress
(
"BNG"
);
data1
.
setIndustryType
(
"Telecom"
);
data1
.
setStatus
(
"Y"
);
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
"16101"
);
list
.
add
(
"16102"
);
list
.
add
(
"16103"
);
data1
.
setDeliveryManagers
(
list
);
Account
data2
=
new
Account
();
//data2.setId(new ObjectId("9976ef15874c902c98b8a05d"));
data2
.
setAccountId
(
"Acc004"
);
data2
.
setAccountName
(
"Govt"
);
data2
.
setAccountProjectSequence
(
4
);
data2
.
setClientAddress
(
"HYD"
);
data2
.
setIndustryType
(
"Telecom"
);
data2
.
setStatus
(
"Y"
);
List
<
String
>
list2
=
new
ArrayList
<>();
list2
.
add
(
"16103"
);
list2
.
add
(
"16105"
);
list2
.
add
(
"16107"
);
data1
.
setDeliveryManagers
(
list
);
map1
.
put
(
new
ObjectId
(
"5976ef15874c902c98b8a05d"
),
data1
);
map2
.
put
(
new
ObjectId
(
"9976ef15874c902c98b8a05d"
),
data2
);
data
.
add
(
map1
);
data
.
add
(
map2
);
return
data
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment