@Test public void testSaveTwoRootObjectsWithNoType() { JsonNode expected = mapper .createArrayNode() .add(mapper.createObjectNode().put("userId", "1").put("name", "Paul")) .add( mapper .createObjectNode() .put("userId", "2") .put("name", "Anna") .put("sex", "FEMALE")); User u1 = ModelFactory.eINSTANCE.createUser(); u1.setUserId("1"); u1.setName("Paul"); User u2 = ModelFactory.eINSTANCE.createUser(); u2.setUserId("2"); u2.setName("Anna"); u2.setSex(Sex.FEMALE); Resource resource = new JsonResource(URI.createURI("test"), mapper); resource.getContents().add(u1); resource.getContents().add(u2); JsonNode result = mapper.valueToTree(resource); assertEquals(expected, result); }
public static User fromUserMentionEntity(UserMentionEntity tuser) { User user = new User(); user.setUserId(tuser.getId()); return user; }
public Integer create(User user) { if (user == null) { throw new RuntimeException("Unable to create User. User object is null."); } Integer userId = this.getMaxUserId(); user.setUserId(userId); USERS_TABLE.put(userId, user); return userId; }
public static Pair<Boolean, String> updateProject( ProjectDTO projectDTO, boolean changedProjectName, String originalProjectName) { try { // Additional duplication control Project existingProject; if (changedProjectName) { existingProject = ProxyManager.getProjectProxy().findProjectByName(projectDTO.getName()); } else existingProject = null; if (existingProject != null && changedProjectName) { System.out.println("Existing project exists!"); return Pair.of(false, "Project with this name already exists!"); } Project p = ProxyManager.getProjectProxy().findProjectByName(originalProjectName); p.setProjectId(projectDTO.getProjectId()); p.setName(projectDTO.getName()); p.setDescription(projectDTO.getDescription()); p.setStatus(projectDTO.getStatus()); Team team = new Team(); team.setTeamId(projectDTO.getTeamTeamId().getTeamId()); team.setScrumMasterId(projectDTO.getTeamTeamId().getScrumMasterId()); team.setProductOwnerId(projectDTO.getTeamTeamId().getProductOwnerId()); List<User> userList = new ArrayList<User>(); if (projectDTO.getTeamTeamId().getUserList() != null) { for (UserDTO userDTO : projectDTO.getTeamTeamId().getUserList()) { User user = new User(); user.setUserId(userDTO.getUserId()); user.setUsername(userDTO.getUsername()); user.setPassword(userDTO.getPassword()); user.setFirstName(userDTO.getFirstName()); user.setLastName(userDTO.getLastName()); user.setEmail(userDTO.getEmail()); user.setIsAdmin(userDTO.isAdmin()); user.setSalt(userDTO.getSalt()); user.setIsActive(userDTO.isActive()); user.setTimeCreated(userDTO.getTimeCreated()); userList.add(user); } team.setUserList(userList); } else return Pair.of(false, "No project list when saving team."); p.setTeamTeamId(team); try { if (p == null) return Pair.of(false, "Data error!"); ProxyManager.getProjectProxy().edit(p); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); return Pair.of(false, e.getMessage()); } } catch (Exception e) { e.printStackTrace(); return Pair.of(false, e.getMessage()); } return Pair.of(true, "Project updated successfully."); }
public void testStoring() throws Throwable { System.out.println("Storing...???"); User lazar = new User(); lazar.setUserId("LZ"); lazar.setUserName("Lazar"); dbSess.startTransaction(); UserFactory.getInstance().store(dbSess, lazar); dbSess.commitTransaction(); System.out.println("Done"); }
public static User fromUser(twitter4j.User tuser) { User user = new User(); user.setUserId(tuser.getId()); user.setFollowers(tuser.getFollowersCount()); user.setLocation(tuser.getLocation()); return user; }
public static Pair<Boolean, String> saveNewProject(ProjectDTO projectDTO) { // check for project in database System.out.println("Project to check in base: " + projectDTO.getName()); Project existingProject = ProxyManager.getProjectProxy().findProjectByName(projectDTO.getName()); try { if (existingProject != null) { System.out.println("Existing project exists!"); return Pair.of(false, "Project with this name already exists!"); } else System.out.println("Project check passed, no existing project."); Project p = new Project(); p.setName(projectDTO.getName()); p.setDescription(projectDTO.getDescription()); p.setStatus(projectDTO.getStatus()); Team team = new Team(); team.setTeamId(projectDTO.getTeamTeamId().getTeamId()); team.setScrumMasterId(projectDTO.getTeamTeamId().getScrumMasterId()); team.setProductOwnerId(projectDTO.getTeamTeamId().getProductOwnerId()); List<User> userList = new ArrayList<User>(); if (projectDTO.getTeamTeamId().getUserList() != null) { for (UserDTO userDTO : projectDTO.getTeamTeamId().getUserList()) { User user = new User(); user.setUserId(userDTO.getUserId()); user.setUsername(userDTO.getUsername()); user.setPassword(userDTO.getPassword()); user.setFirstName(userDTO.getFirstName()); user.setLastName(userDTO.getLastName()); user.setEmail(userDTO.getEmail()); user.setIsAdmin(userDTO.isAdmin()); user.setSalt(userDTO.getSalt()); user.setIsActive(userDTO.isActive()); user.setTimeCreated(userDTO.getTimeCreated()); userList.add(user); } team.setUserList(userList); } else return Pair.of(false, "No user list when saving team."); p.setTeamTeamId(team); try { if (p == null) return Pair.of(false, "Data error!"); ProxyManager.getProjectProxy().create(p); } catch (Exception e) { System.err.println("Error: " + e.getMessage()); return Pair.of(false, e.getMessage()); } } catch (Exception e) { e.printStackTrace(); return Pair.of(false, e.getMessage()); } return Pair.of(true, "Project saved successfully."); }
@Test public void testSaveSingleObjectWithNoType() { JsonNode expected = mapper.createObjectNode().put("userId", "1").put("name", "Paul"); User u1 = ModelFactory.eINSTANCE.createUser(); u1.setUserId("1"); u1.setName("Paul"); JsonNode result = mapper.valueToTree(u1); assertEquals(expected, result); }
public static void obfuscateUserNames(Tweet tweet) { String message = tweet.getMessage(); for (User mention : tweet.getMentioned()) { mention.setUserId(mention.getAccountName().hashCode()); message = message.replace(mention.getAccountName(), String.format("@%s", mention.getUserId())); mention.setAccountName("omitted"); } tweet.setMessage(message); }
public void addTestCaseExecutionDetails() throws Exception { activityObj.setActivityId("001"); testCaseObj.setActivityObj(activityObj); testCaseObj.setTestCaseId("001"); userObj.setUserId("12"); testCaseObj.setUserObj(userObj); testCaseObj.setActualDate(new Date(1970, 01, 01)); testCaseObj.setTestCaseStatus("complete"); testCaseObj.setComments("better"); testCaseObj.setActualBehaviour("got value"); System.out.println(tmsManager.addTestCaseExecutionDetails(testCaseObj)); }
public void createTestCase() throws Exception { testCaseObj.setTestCaseId("15"); testCaseObj.setTestCaseDescription("this s Next testcase Description"); testCaseObj.setTestCasePhase("normal "); Project projectObj = new Project(); projectObj.setProjectId("2"); testCaseObj.setProjectObj(projectObj); User userObj = new User(); userObj.setUserId("123"); testCaseObj.setUserObj(userObj); Activity activityObj = new Activity(); activityObj.setActivityId("001"); testCaseObj.setActivityObj(activityObj); testCaseObj.setExpectedBehaviour("Bad"); System.out.println(tmsManager.createTestCase(testCaseObj)); }
@SuppressWarnings("unchecked") private User parseUser(final Element element) throws RESTLightClientException { User user = new User(); user.setResourceURI(element.getChildText(RESOURCE_URI_ELEMENT)); user.setUserId(element.getChildText(USER_ID_ELEMENT)); user.setName(element.getChildText(USER_NAME_ELEMENT)); user.setStatus(element.getChildText(USER_STATUS_ELEMENT)); user.setEmail(element.getChildText(USER_EMAIL_ELEMENT)); Element roles = element.getChild(USER_ROLES_ELEMENT); if (roles != null) { for (Element role : (List<Element>) roles.getChildren(USER_ROLE_ELEMENT)) { user.getRoles().add(role.getValue()); } } user.setUserManaged( element.getChildText(USER_USER_MANAGED_ELEMENT).equals("true") ? true : false); return user; }
@Test public void testSaveSingleObjectWithNoTypeAndOneContainment() { JsonNode expected = mapper .createObjectNode() .put("userId", "1") .put("name", "Paul") .set("address", mapper.createObjectNode().put("addId", "a1").put("city", "Prague")); User u1 = ModelFactory.eINSTANCE.createUser(); u1.setUserId("1"); u1.setName("Paul"); Address add = ModelFactory.eINSTANCE.createAddress(); add.setAddId("a1"); add.setCity("Prague"); u1.setAddress(add); JsonNode result = mapper.valueToTree(u1); assertEquals(expected, result); }