• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DtoFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.che.dto.server.DtoFactory的典型用法代码示例。如果您正苦于以下问题:Java DtoFactory类的具体用法?Java DtoFactory怎么用?Java DtoFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DtoFactory类属于org.eclipse.che.dto.server包,在下文中一共展示了DtoFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: classFileNavigation

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
private OpenDeclarationDescriptor classFileNavigation(IClassFile classFile, IJavaElement element)
    throws JavaModelException {
  OpenDeclarationDescriptor dto =
      DtoFactory.getInstance().createDto(OpenDeclarationDescriptor.class);
  dto.setPath(classFile.getType().getFullyQualifiedName());
  dto.setLibId(classFile.getAncestor(IPackageFragmentRoot.PACKAGE_FRAGMENT_ROOT).hashCode());
  dto.setBinary(true);
  if (classFile.getSourceRange() != null) {
    if (element instanceof ISourceReference) {
      ISourceRange nameRange = ((ISourceReference) element).getNameRange();
      dto.setOffset(nameRange.getOffset());
      dto.setLength(nameRange.getLength());
    }
  }
  return dto;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:JavaNavigation.java


示例2: toPackageFragments

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
private List<PackageFragment> toPackageFragments(IPackageFragmentRoot packageFragmentRoot)
    throws JavaModelException {
  IJavaElement[] children = packageFragmentRoot.getChildren();
  if (children == null) {
    return null;
  }
  List<PackageFragment> result = new ArrayList<>();
  for (IJavaElement child : children) {
    if (child instanceof IPackageFragment) {
      IPackageFragment packageFragment = (IPackageFragment) child;
      PackageFragment fragment = DtoFactory.newDto(PackageFragment.class);
      fragment.setElementName(packageFragment.getElementName());
      fragment.setPath(packageFragment.getPath().toOSString());
      fragment.setProjectPath(packageFragment.getJavaProject().getPath().toOSString());
      result.add(fragment);
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:JavaNavigation.java


示例3: testGradleProject

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void testGradleProject() throws Exception {
    UsersWorkspaceDto usersWorkspaceMock = mock(UsersWorkspaceDto.class);
    when(httpJsonRequestFactory.fromLink(eq(DtoFactory.newDto(Link.class)
                                                      .withMethod("GET")
                                                      .withHref(API_ENDPOINT + "/workspace/" + workspace))))
            .thenReturn(httpJsonRequest);
    when(httpJsonRequestFactory.fromLink(eq(DtoFactory.newDto(Link.class)
                                                      .withMethod("PUT")
                                                      .withHref(API_ENDPOINT + "/workspace/" + workspace + "/project"))))
            .thenReturn(httpJsonRequest);
    when(httpJsonRequest.request()).thenReturn(httpJsonResponse);
    when(httpJsonResponse.asDto(UsersWorkspaceDto.class)).thenReturn(usersWorkspaceMock);
    final ProjectConfigDto projectConfig = DtoFactory.getInstance().createDto(ProjectConfigDto.class)
                                                     .withName("project")
                                                     .withPath("/myProject")
                                                     .withType(Constants.PROJECT_TYPE_ID);
    when(usersWorkspaceMock.getProjects()).thenReturn(Collections.singletonList(projectConfig));

    Project project = pm.createProject(workspace, "myProject",
                                       DtoFactory.getInstance().createDto(ProjectConfigDto.class)
                                                 .withType(Constants.PROJECT_TYPE_ID),
                                       null);

    Assert.assertEquals(project.getConfig().getType(), Constants.PROJECT_TYPE_ID);
}
 
开发者ID:vzhukovskii,项目名称:che-gradle-plugin,代码行数:27,代码来源:GradleProjectTypeIntegrationTest.java


示例4: shouldSendEmailWhenUserWasCreatedByUserServiceWithToken

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void shouldSendEmailWhenUserWasCreatedByUserServiceWithToken() throws Throwable {
  // preparing user creator's method
  final Method method =
      UserService.class.getMethod("create", UserDto.class, String.class, Boolean.class);
  when(invocation.getMethod()).thenReturn(method);

  final Object[] invocationArgs = new Object[method.getParameterCount()];
  invocationArgs[1] = "token123";
  when(invocation.getArguments()).thenReturn(invocationArgs);

  when(invocation.proceed()).thenReturn(response);
  when(response.getEntity())
      .thenReturn(DtoFactory.newDto(UserDto.class).withEmail(recipient).withName("user123"));

  interceptor.invoke(invocation);

  verify(notificationSender).sendNotification(eq("user123"), eq(recipient), eq(false));
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:20,代码来源:CreateUserInterceptorTest.java


示例5: shouldSendEmailWhenUserWasCreatedByUserServiceWithDescriptor

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void shouldSendEmailWhenUserWasCreatedByUserServiceWithDescriptor() throws Throwable {
  // preparing user creator's method
  final Method method =
      UserService.class.getMethod("create", UserDto.class, String.class, Boolean.class);
  when(invocation.getMethod()).thenReturn(method);

  final Object[] invocationArgs = new Object[method.getParameterCount()];
  when(invocation.getArguments()).thenReturn(invocationArgs);

  when(invocation.proceed()).thenReturn(response);
  when(response.getEntity())
      .thenReturn(DtoFactory.newDto(UserDto.class).withEmail(recipient).withName("user123"));

  interceptor.invoke(invocation);

  verify(notificationSender).sendNotification(eq("user123"), eq(recipient), eq(true));
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:19,代码来源:CreateUserInterceptorTest.java


示例6: shouldStoreInvite

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test(dataProvider = "supportedDomains")
public void shouldStoreInvite(String domain) throws Exception {
  when(userManager.getByEmail(anyString())).thenThrow(new NotFoundException(""));
  when(inviteDao.store(any())).thenReturn(Optional.empty());
  InviteDto toStore =
      DtoFactory.newDto(InviteDto.class)
          .withDomainId(domain)
          .withInstanceId("instance123")
          .withActions(asList("read", "update"))
          .withEmail("[email protected]");

  inviteManager.store(toStore);

  verify(permissionsManager).checkActionsSupporting(domain, asList("read", "update"));
  verify(userManager).getByEmail("[email protected]");
  verify(inviteDao).store(new InviteImpl(toStore));
  verify(eventService).publish(any(InviteCreatedEvent.class));
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:19,代码来源:InviteManagerTest.java


示例7: shouldUpdateInvite

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test(dataProvider = "supportedDomains")
public void shouldUpdateInvite(String domain) throws Exception {
  when(userManager.getByEmail(anyString())).thenThrow(new NotFoundException(""));
  when(inviteDao.store(any())).thenReturn(Optional.of(new InviteImpl()));
  InviteDto toStore =
      DtoFactory.newDto(InviteDto.class)
          .withDomainId(domain)
          .withInstanceId("instance123")
          .withActions(asList("read", "update"))
          .withEmail("[email protected]");

  inviteManager.store(toStore);

  verify(permissionsManager).checkActionsSupporting(domain, asList("read", "update"));
  verify(userManager).getByEmail("[email protected]");
  verify(inviteDao).store(new InviteImpl(toStore));
  verify(eventService, never()).publish(any());
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:19,代码来源:InviteManagerTest.java


示例8: shouldCheckPermissionsOnInviteStoring

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void shouldCheckPermissionsOnInviteStoring() throws Exception {
  InviteDto toStore =
      DtoFactory.newDto(InviteDto.class)
          .withEmail("[email protected]")
          .withDomainId("test")
          .withInstanceId("test123")
          .withActions(Collections.singletonList("read"));

  given()
      .auth()
      .basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
      .contentType("application/json")
      .body(toStore)
      .when()
      .expect()
      .statusCode(204)
      .post(SECURE_PATH + "/invite");

  verify(service).invite(toStore);
  verify(subject).hasPermission("test", "test123", SET_PERMISSIONS);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:23,代码来源:InviteServicePermissionsFilterTest.java


示例9: shouldRespond403WhenUserDoesNotHaveCorrespondingPermissionOnInviteStoring

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void shouldRespond403WhenUserDoesNotHaveCorrespondingPermissionOnInviteStoring()
    throws Exception {
  when(subject.hasPermission(anyString(), anyString(), anyString())).thenReturn(false);

  given()
      .auth()
      .basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
      .contentType("application/json")
      .body(
          DtoFactory.newDto(InviteDto.class)
              .withEmail("[email protected]")
              .withDomainId("test")
              .withInstanceId("test123")
              .withActions(Collections.singletonList("read")))
      .when()
      .expect()
      .statusCode(403)
      .post(SECURE_PATH + "/invite");

  verify(service, never()).invite(any());
  verify(subject).hasPermission("test", "test123", SET_PERMISSIONS);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:24,代码来源:InviteServicePermissionsFilterTest.java


示例10: shouldConvertInvitesToPermissionsWhenUserCreated

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void shouldConvertInvitesToPermissionsWhenUserCreated() throws Exception {
  InviteImpl invite1 =
      new InviteImpl(
          USER_EMAIL, OrganizationDomain.DOMAIN_ID, "org123", asList("read", "update"));
  InviteImpl invite2 =
      new InviteImpl(USER_EMAIL, WorkspaceDomain.DOMAIN_ID, "ws321", singletonList("delete"));
  Permissions expectedPermission1 = convert(invite1);
  Permissions expectedPermission2 = convert(invite2);
  doReturn(new Page<>(singletonList(invite1), 0, 1, 2))
      .doReturn(new Page<>(singletonList(invite2), 1, 1, 2))
      .when(inviteManager)
      .getInvites(anyString(), anyInt(), anyLong());

  converter.onEvent(
      new UserCreatedEvent(
          DtoFactory.newDto(UserDto.class).withEmail(USER_EMAIL).withId(USER_ID)));

  verify(inviteManager, times(2)).getInvites(eq(USER_EMAIL), anyInt(), anyLong());
  verify(inviteManager).remove(invite1.getDomainId(), invite1.getInstanceId(), USER_EMAIL);
  verify(inviteManager).remove(invite2.getDomainId(), invite2.getInstanceId(), USER_EMAIL);
  verify(permissionsManager).storePermission(expectedPermission1);
  verify(permissionsManager).storePermission(expectedPermission2);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:25,代码来源:InviteToPermissionsConverterTest.java


示例11: shouldSkipInviteWhenExceptionOccursOnInviteConverting

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void shouldSkipInviteWhenExceptionOccursOnInviteConverting() throws Exception {
  InviteImpl invite1 =
      new InviteImpl(
          USER_EMAIL, OrganizationDomain.DOMAIN_ID, "org123", asList("read", "update"));
  InviteImpl invite2 =
      new InviteImpl(USER_EMAIL, WorkspaceDomain.DOMAIN_ID, "ws321", singletonList("delete"));
  Permissions expectedPermission2 = convert(invite2);
  doReturn(new Page<>(singletonList(invite1), 0, 1, 2))
      .doReturn(new Page<>(singletonList(invite2), 1, 1, 2))
      .when(inviteManager)
      .getInvites(anyString(), anyInt(), anyLong());
  doThrow(new ConflictException("")).doNothing().when(permissionsManager).storePermission(any());

  converter.onEvent(
      new UserCreatedEvent(
          DtoFactory.newDto(UserDto.class).withEmail(USER_EMAIL).withId(USER_ID)));

  verify(inviteManager, times(2)).getInvites(eq(USER_EMAIL), anyInt(), anyLong());
  verify(inviteManager).remove(invite2.getDomainId(), invite2.getInstanceId(), USER_EMAIL);
  verify(permissionsManager).storePermission(expectedPermission2);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:23,代码来源:InviteToPermissionsConverterTest.java


示例12: shouldReturnAllUsers

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void shouldReturnAllUsers() throws Exception {
  UserImpl testUser = new UserImpl("test_id", "[email protected]", "name");
  when(userManager.getAll(anyInt(), anyLong()))
      .thenReturn(new Page<>(singletonList(testUser), 0, 1, 1));

  final Response response =
      given()
          .auth()
          .basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
          .when()
          .get(SECURE_PATH + "/admin/user?maxItems=3&skipCount=4");

  assertEquals(response.getStatusCode(), OK.getStatusCode());
  verify(userManager).getAll(3, 4);

  List<UserDto> users =
      DtoFactory.getInstance().createListDtoFromJson(response.getBody().print(), UserDto.class);
  assertEquals(users.size(), 1);
  final UserDto fetchedUser = users.get(0);
  assertEquals(fetchedUser.getId(), testUser.getId());
  assertEquals(fetchedUser.getEmail(), testUser.getEmail());
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:24,代码来源:AdminUserServiceTest.java


示例13: throwsBadRequestExceptionWhenMissedEmailAndNameParts

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void throwsBadRequestExceptionWhenMissedEmailAndNameParts() throws Exception {
  final Response response =
      given()
          .auth()
          .basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
          .when()
          .expect()
          .statusCode(400)
          .get(SECURE_PATH + "/admin/user/find");

  final String actual =
      DtoFactory.getInstance()
          .createDtoFromJson(response.body().print(), ServiceError.class)
          .getMessage();
  assertEquals(actual, "Missed user's e-mail/name part");
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:18,代码来源:AdminUserServiceTest.java


示例14: throwsBadRequestExceptionWhenProvidedTwoSearchParams

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void throwsBadRequestExceptionWhenProvidedTwoSearchParams() throws Exception {
  final Response response =
      given()
          .auth()
          .basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
          .when()
          .expect()
          .statusCode(400)
          .get(SECURE_PATH + "/admin/user/[email protected]&namePart=admin");

  final String actual =
      DtoFactory.getInstance()
          .createDtoFromJson(response.body().print(), ServiceError.class)
          .getMessage();
  assertEquals(actual, "Expected either user's e-mail or name part, while both values received");
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:18,代码来源:AdminUserServiceTest.java


示例15: throwsServerExceptionWhenAnyInternalServerErrorOccur

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void throwsServerExceptionWhenAnyInternalServerErrorOccur() throws Exception {
  final String errMsg = "server error";
  when(userManager.getByEmailPart(nullable(String.class), anyInt(), anyLong()))
      .thenThrow(new ServerException(errMsg));
  final Response response =
      given()
          .auth()
          .basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD)
          .when()
          .expect()
          .statusCode(500)
          .get(SECURE_PATH + "/admin/user/[email protected]");

  final String actual =
      DtoFactory.getInstance()
          .createDtoFromJson(response.body().print(), ServiceError.class)
          .getMessage();
  assertEquals(actual, errMsg);
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:21,代码来源:AdminUserServiceTest.java


示例16: shouldReturnBadRequestIfLoginIsNotSet

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void shouldReturnBadRequestIfLoginIsNotSet() throws Exception {
  // given
  // when
  given()
      .contentType(ContentType.JSON)
      .body(
          DtoFactory.getInstance()
              .createDto(Credentials.class)
              .withUsername(null)
              .withPassword("secret"))
      .then()
      .expect()
      .statusCode(400)
      .when()
      .post("/auth/login");
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:18,代码来源:AuthenticationServiceTest.java


示例17: shouldReturnBadRequestIfLoginIsEmpty

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void shouldReturnBadRequestIfLoginIsEmpty() throws Exception {
  // given
  // when
  given()
      .contentType(ContentType.JSON)
      .body(
          DtoFactory.getInstance()
              .createDto(Credentials.class)
              .withUsername("")
              .withPassword("secret"))
      .then()
      .expect()
      .statusCode(400)
      .when()
      .post("/auth/login");
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:18,代码来源:AuthenticationServiceTest.java


示例18: shouldReturnBadRequestIfPassowordIsNotSet

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void shouldReturnBadRequestIfPassowordIsNotSet() throws Exception {
  // given
  // when
  given()
      .contentType(ContentType.JSON)
      .body(
          DtoFactory.getInstance()
              .createDto(Credentials.class)
              .withUsername(USER.getName())
              .withPassword(null))
      .then()
      .expect()
      .statusCode(400)
      .when()
      .post("/auth/login");
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:18,代码来源:AuthenticationServiceTest.java


示例19: shouldReturnBadRequestIfPasswordIsEmpty

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void shouldReturnBadRequestIfPasswordIsEmpty() throws Exception {
  // given
  // when
  given()
      .contentType(ContentType.JSON)
      .body(
          DtoFactory.getInstance()
              .createDto(Credentials.class)
              .withUsername(USER.getName())
              .withPassword(""))
      .then()
      .expect()
      .statusCode(400)
      .when()
      .post("/auth/login");
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:18,代码来源:AuthenticationServiceTest.java


示例20: shouldReturnBadRequestIfHandlerNotAbleToAuthenticate

import org.eclipse.che.dto.server.DtoFactory; //导入依赖的package包/类
@Test
public void shouldReturnBadRequestIfHandlerNotAbleToAuthenticate() throws Exception {
  // given
  doThrow(new AuthenticationException("Not able to authenticate"))
      .when(handler)
      .authenticate(eq(USER.getName()), eq("asdfasdf"));
  // when
  given()
      .contentType(ContentType.JSON)
      .body(
          DtoFactory.getInstance()
              .createDto(Credentials.class)
              .withUsername(USER.getName())
              .withPassword("asdfasdf"))
      .then()
      .expect()
      .statusCode(400)
      .when()
      .post("/auth/login");
}
 
开发者ID:codenvy,项目名称:codenvy,代码行数:21,代码来源:AuthenticationServiceTest.java



注:本文中的org.eclipse.che.dto.server.DtoFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ScheduleHelper类代码示例发布时间:2022-05-23
下一篇:
Java Attribute类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap